I have fscanf to read lines of setting from a configuration file. Those settings have strictly predefined format which looks like
name1=option1;
name2=option2;
...
so basically I do
fscanf(configuration,"%[^=]=%[^;];",name,option);
where configuration is the file stream and name and option are programming buffers.
The problem is that the name buffer contains a newline character I don't want. Is there format specifier I've missed in the "[^...]" set to skip newline character? Anyway, can it be solved through format specifier ever?
BTW: Swallowing the newline character by writting this
"%[^=]=%[^;];
"
is not elegent I think for that the newline character could repeat more than once anywhere.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…