fscanf and newline character

前端 未结 3 1755
南笙
南笙 2020-12-17 15:30

I have fscanf to read lines of setting from a configuration file. Those settings have strictly predefined format which looks like

name1=option1;
name2=option         


        
3条回答
  •  爱一瞬间的悲伤
    2020-12-17 16:05

    This will work:

    fscanf(configuration,"%[^=]=%[^;];%[^\n]",name,option,dummy);

    You will have to consume the new line character.Otherwise,the newline is left in the input stream.

提交回复
热议问题