I was able to skip lines with scanf with the following instruction:
fscanf(config_file, "%*[^
]
");
The format string matches a line containing any character including spaces. The *
in the format string means we are not interested in saving the line, but just in incrementing the file position.
Format string explanation:
%
is the character which each scanf format string starts with;
*
indicates to not put the found pattern anywhere (typically you save pattern found into parameters after the format string, in this case the parameter is NULL);
[^
]
means any character except newline;
means newline;
so the [^
]
means a full text line ending with newline.
Reference here.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…