Why these two are not equal?

c, file-io

Solution

When using `fscanf`, if you specify one or more whitespace characters in the format string, it will skip any amount of whitespace from the input. It makes no difference which whitespace characters you specified or how many. So in this case when you put `\r\n` in the format string, it actually skips both the newline sequence and the spaces at the beginning of the next line.

Problem

The First Code Fragment ``` fscanf (Fp, "%d",&Variable); fseek (Fp, 2, SEEK_CUR); // Ignore <Enter>: 0x0D 0x0A (Windows Platform) fread (&String, sizeof(char), Length, Fp); ``` The Second Code Fragment ``` fscanf (Fp, "%d\r\n",&Variable); // Ignore <Enter>: 0x0D 0x0A (Windows Platform) fread (&String, sizeof(char), Length, Fp); ``` The Input File ``` 13 Foobar ``` The first code can get the four white-blanks before Foobar, but the second can't. Why? Thanks. PS: If can, please help me rename the topic to make it more specific. Appreciate your help.

Original source