Hi,
How do you read a text file and display it on screen. Its just a text file NEW.TXT. Does anyone have an example? or can tell me how to do it?
thanks
Kendals
Hi,
How do you read a text file and display it on screen. Its just a text file NEW.TXT. Does anyone have an example? or can tell me how to do it?
thanks
Kendals
char tempStr[128];
FILE *fPtr = fopen("NEW.TXT", "r");
while(!feof(fPtr)) {
fgets(tempStr, 80, fPtr);
fprintf(stderr,"%s\n", tempStr);
}
Hi,
Once i have loaded my text file how do i go next and back to view the next records and previous records?
do you have an example of this using an array?
thanks
Kendals
Hi,
I tried your code and i cannot get it to read the whole txt file.
Your code only reads the first line?
Can you help?
thanks
kendals
Are you just trying to dump the entire contents to the screen?
You really should read up on the f* functions and learn a bit more on how they work.Code:FILE *fp = fopen( "myfile.txt", "r" ); int c; while ( (c=fgetc(fp)) != EOF ) printf("%c", c );
Additionally, you may want to use psesudo code to explain your problem first:
As per above, if you used a loop with the previous poster's code, you'd have your answer already.Code:while we're not at the end of the file read a line put the line on the screen
Quzah.
Hope is the first step on the road to disappointment.