I'm reading a text file with this format:
DUMMY,0000000000000100100000000000000000
JOHNDOE,0000000000000010000000100000000100
FOO,0000000000000000000000000100000000
BAR,1000000100000000000000000000000000
When using fgets like this:
while (fgets(line, linelength, stream) != NULL) {
...
}
It always get three junk characters in the first line. I tried deleting the first line with a plain text editor just to test there's nothing like non-printable characters before the text, with no results. They are always the same three chars. The first line, when readed by fgets looks like this in the Visual Studio debugging console:
DUMMY,0000000000000100100000000000000000
When used printf to show on the terminal, it looks like this:
DUMMY,0000000000000100100000000000000000
As said above, if I delete the first line of the input file, then the next line also has the same characters:
JOHNDOE,0000000000000010000000100000000100
Funny thing, if I put an empty line as the first one in the input file, everything seems to be OK.