473,386 Members | 1,754 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

need expert help


I have two file.
file looks like this:

first file:

A#b1#c1
B#b2#c2
B#b3
C#b4#c4
D#b5#c5

second file:

B#q1
C#q2
C#q3
E#q4
F#q5

I need to write programm that simulates simple database and each table
is given by text file where each row represent one entry and fileds are
delimited with # mark.
first field is key of row and there can be more rows with same key.
So I need to write programm that will take those two file and print all
rows that have same keys( ).

I've got instructions : need to save row that matches
in the hash table(need to choose function that fits)
so that key of hash table is key of row and a value in hash table is a
pointer on the beginning of linked list
....if you understand what is the problem..

one of possible outputs:

B#b2#c2#q1
B#b3#q1
C#b4#c4#q2
C#b4#c4#q3

P.S I only dont undestrand how to write this part with hash table(newer
use it before) so if you can please explain me on example or if you can
write just this part with filling the hash table and reading the data
from hash table..
(If you are asking, yes this is my homework and I should write this on
my own, but it's easily for me to understand if I first read someone
else code...thanks)

I tried something:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

int main(int argc, char *argv[]){

char *fn1, *fn2;
FILE *fstream1,*fstream2;

char* buff_d1, *buff_d2;

char search_s ='#';
int real_s;
if(argc!=3) exit(0);

fn1 = argv[1];
fn2 = argv[2];

if(!(fstream1 = fopen(fn1,"r")) || !(fstream2 = fopen(fn2,"r")))
exit(1);

search_s ='#';
buff_d1 = malloc(1);
buff_d2 = malloc(1);

real_s = 1;
while(!feof(fstream1)){

*buff_d1 = fgetc(fstream1);

if(!(buff_d1 = realloc(buff_d1,++real_s)))
exit(1);

}

real_s = 1;
while(!feof(fstream2)){

*buff_d2 = fgetc(fstream2);

if(!(buff_d2 = realloc(buff_d2,++real_s)))
exit(1);

}
//and now what?
// now I think that with "strtok(buff_d1,search_s)" put

free(buff_d1);
free(buff_d2);

return 0;
}
best regards
Sinisa

Nov 14 '05 #1
0 1073

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: mark | last post by:
Hello- i am trying to make the function addbitwise more efficient. the code below takes an array of binary numbers (of size 5) and performs bitwise addition. it looks ugly and it is not elegant...
1
by: Kate Luu | last post by:
I have down load some source codes from the internet and it wasn't worked right, but I'm really know what's wrong about it. May some expert help me please...I'm deeply appreciated for your help....
4
by: Cpierswim | last post by:
I am a Java developer who uses J#. I really like the express edition stuff (the word completion tool alone makes J# better than any other Java development software), but I get ticked off about how...
10
by: L. R. Du Broff | last post by:
I own a small business. Need to track a few hundred pieces of rental equipment that can be in any of a few dozen locations. I'm an old-time C language programmer (UNIX environment). If the only...
3
by: apattin | last post by:
Hi all, I need some expert advice on a ROLLUP fine point. summary_table table has 4 columns: file_id primary_site morphology primary
23
by: vinod.bhavnani | last post by:
Hello all, I need desperate help Here is the problem: My problem today is with multidimensional arrays. Lets say i have an array A this is a 4 dimensional static array.
0
by: Damon | last post by:
I've been pulling my hair out over this and I need some expert help. I'm trying to access an XML API using cURL over SSL. Here's the API address: ...
0
by: onegative | last post by:
G'day Y'all, I was hoping to get some expert feedback on a proposal I am considering regarding a new internal application to help fill some gaps in our IT department. I have some configuration...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.