PDA

View Full Version : the file problem



juandy
10-05-2001, 06:13 AM
I made a file of records.....each record consists of one integer field......now i wanna retrieve the value from the integer field......how to do that ? i used fscanf function but it doesn't work......the other fields are string value..


while(fgets(code,6,handle)!=NULL)

{ fgets(name,22,handle);

fgets(position,22,handle);

fscanf("%d",&age); // this is the integer value

printf("%s ",code);

printf("%s ",name);

printf("%s ",position);

printf("%-3d\n",age);

}

nvoigt
10-05-2001, 07:22 AM
>i used fscanf function but it doesn't work......

Maybe it went on strike... try to pay more money... :p

Seriously, it will do something. What happens
when you run it ? What does it print ?

juandy
10-05-2001, 08:04 AM
I have corrected it.....the problem was i forgot to put the file stream pointer in the fscanf function......btw...thank's for your kindness.....:)

nvoigt
10-05-2001, 08:05 AM
oh... damn, you're right, I didn't even notice... whoops ;)

juandy
10-05-2001, 08:28 AM
I have corrected it.....the problem was i forgot to put the file stream pointer in the fscanf function......btw...thank's for your kindness.....:)