fgets() doesn't know the difference between characters, such as 'a', 'b', 'c' ... and numbers such as '1', '2', '3' ... '9'. In the file they are all just text. If you want to treat all those numbers as text, read the file line by line, then just use fgets() the normal way
char line[80]
FILE* fp = fopen("data.inp","r");
while(fgets(line,1,sizeof(line),fp)
{
// do something
}
fclose(fp);
If you just want to add more lines to that file, then it isn't necessary to read it at all. Open the file for append and start writing -- new lines will be appended to the end of the existing lines.
Last edited by Ancient Dragon; Feb 5th, 2007 at 9:38 am.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Offline 21,947 posts
since Aug 2005