Michael said:
Hi,
Thanks for all the advice. I just wound up using fgetc() and as soon as
it returned whitespace that was not a space, I assume end of line. In
my case the file contains space seperated fields, so a whitespace that
is not a space must be EOL. Is there explicitly an EOL character that
is OS independent?
I would like to make my design more robust to actually check for an
EOL.
Michael
Choice of fgetc() and/or fgets() makes a lot of sense to me. Also,
reading from a text file is a very exact exercise. You must know exactly
how this file was constructed in order to read it successfully. There
are few Standards in this regard. You have to know your file.
Generally, text files are comprised of lines of characters, each line
ending with the '\n' character. There may be any number of lines.
Whether the last line in the file is ended with '\n' is an
implementation detail. Usually it is.
Again, we have to know our file to make sense of it. You mention above
separated fields in text files. This suggests to me a database table of
rows and columns presented to us as text. Simply separating fields with
spaces is not normally useful.