im wanting to read from a file...now, maybe im misunderstanding how reading from a file works...but i when i read in from my text file, the last line isnt showing up?...like the last line in the text file.
heres the info in the text file..
Assume that someone is typing his final report for english class
into a text file. After completing the report, he realized that
he mistakenly had the caps lock key on throughout the typing process. He said
oh my gosh what have i done? How am i going to fix this? Blah Blah Blah.
Code:
#include <stdio.h>
int main()
{
char sentence[1024];
FILE *rptPTR; /* file pointer to the report*/
if (( rptPTR = fopen("report.txt", "r+") ) == NULL )
{
printf("File could not be opened!\n");
}
else
{
fgets(sentence, 1024, rptPTR);
while( !feof(rptPTR))
{
printf("%s", sentence);
fgets(sentence, 1024, rptPTR);
}
fclose(rptPTR);
}
return 0;
}
windows xp using MSVC 6