Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > need expert help

Reply
Thread Tools

need expert help

 
 
sipetar@inet.hr
Guest
Posts: n/a
 
      02-23-2005

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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
which processer is best?? i need help you expert to decide niljaviya Hardware 0 11-02-2006 04:05 AM
Need help from .NEt remote expert ?? =?Utf-8?B?c2VyZ2UgY2FsZGVyYXJh?= MCSD 3 08-12-2006 10:29 AM
Need expert help with sharing a satellite internet system mlsteen1 Wireless Networking 3 03-28-2006 12:21 AM
ATTN; Need EXPERT with registry problems (I know from previous posts someone can help) Twitch Computer Support 6 12-30-2003 07:41 PM
I need help from an expert! Marc Abrahams Computer Information 3 11-18-2003 06:58 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57