Got it!
Remove extra fseek(f, 1, SEEK_CUR);
Each fgets()
reads line including new line.
So the file pointer points at the beginning of the new line.
Your fseek
moves the pointer to the next character which is a new line character (\n
).
atoi()
of an empty string returns 0.
That will do help.
Now, there is one small thing that you make correct. If your mystring
is declared as char mystring[100]
then in each place you call fgets
, change your 100
to sizeof(mystring)
. That is more correct.
I do not understand why you got so many negative points. I am upping your question.