Help me quickly please>>>>>
|
|||
|
Rank: ? (2)
Member #: 29384 |
im trying to read a file has many lines but after reading it every time i tried to printf it, but it always print just the last line???/
f = fopen("text.txt","r" if(!f) return 1; while(fgets(s,1000,f) != NULL) sprintf(value,s); fclose(f); printf("%s",value); |
||
|
|||
|
|||
|
Rank: ? (767)
Member #: 11085 |
Of course it does. Just logically step through your program.
1) Open the file. 2) If the file is not open, return -1. 3) While 1000 characters from the file are capable of being read in... 3.1) Store the characters in the variable s. 3.2) Take the characters from s and store them in the variable value. 4) Close the file. 5) Print out the contents of the variable value. Basically, why do you think the variable value holds ever line of the file? You have no instruction that tells it to do so.
- relpats_eht
|
||
|
|||
|
|||
|
Rank: ? (2)
Member #: 29384 |
Thank you man i get your idea>>>
|
||
|
Please login or register to post a reply.