(sori i just wan to show my zip file so that someone can help me ;( plz dont ban me..... )
this is no joke, pls help me.. i wil be waiting...
Pls reply me if u think u can help me...
Edited by salvate_me, 10 October 2009 - 04:23 PM.
Edited by salvate_me, 10 October 2009 - 04:23 PM.
|
|
|
key * ky_read(FILE * file)
{
int k;
int id;
char str[100];
key * newKey = (key *) malloc(sizeof(key));
if(file==NULL)
{
printf("error opening file!!\n");
getchar();
exit(1);
}
else
{
for(k = 0; k < 10; k++)
{
fscanf(file, "%d %s", &(newKey->id), &str);
newKey->code = (char*)malloc(strlen(str));
strcpy(newKey->code, str);
}
return newKey;
}
}
To start with, you are assuming 10 keys in the file. That is incorrect, based on the problem statement. The number of keys will be in the first line of the text file.
Edited by salvate_me, 10 October 2009 - 05:26 PM.