Code:
char tempStr[128];
FILE *fPtr = fopen("NEW.TXT", "r");
while(!feof(fPtr)) {
fgets(tempStr, 80, fPtr);
fprintf(stderr,"%s\n", tempStr);
}
This code is wrong. Plain and simple.
1. Always check that a file pointer is opened successfully before using it.
2. Don't use feof() in this manner, it doesn't work as you'd expect.
3. Why limit the input to 80 bytes on the fgets(), when the buffer is 128 bytes long ? Not a problem, just a mismatch.
There are plenty of other examples around here...... see what you can come up with, then I'll help again.