Traverse FILE line by line using fscanf

后端 未结 4 838
情话喂你
情话喂你 2021-01-03 03:08

Ok so i have a text file database.txt.

Each line is a user with the format below

\"John Smith\"| 4| 80.00| \"123 Lollipop Lane\"| \"New Jersey\"| \         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-03 04:05

    You should put a blank after specifier "%[^\n] " or use "%[^\n]\n". Both will allow you to skip the newline character.

    fscanf(database, "%[\n] ", buffer);
    

    or

    fscanf(database, "%[\n]\n", buffer);
    

提交回复
热议问题