Subj : Re: fgets function behaves weird To : borland.public.cpp.borlandcpp From : Bob Gonder Date : Thu Oct 14 2004 10:15 am Erwin wrote: >When inspecting sBuffer most of the time a line is read like: >"000145756990027X" "00014575" "1" "1" "07/17/2002" "J" > >However, sometimes a line is read like: >000145756990027X" "00014575" "1" "1" "07/17/2002" "J" > >Whats going on? Is this some sort of bug in the boreland fgets function? I suspect that where that happens, the text file is missing a lf. Or perhaps is cr/lf/lf or some other oddity. Double check your text file with a hex viewer (frhed works well) Search for 0a or 0d and make sure both are always present. (if you search for 0d 0a you will only find what you are _not_ looking for) To speed up the search, you could have your program report the error line, then search for that text in frhed (assuming the X value is somewhat unique) If you are looking for robustness, then open the file in binary mode, and write your own replacement fgets that handles missing (and extra) delimiters. .