fgets() not working after fscanf()

前端 未结 3 1675
误落风尘
误落风尘 2020-12-21 15:49

I am using fscanf to read in the date and then fgets to read the note. However after the first iteration, fscanf returns a value of -1.

I used GDB to debug the progr

3条回答
  •  無奈伤痛
    2020-12-21 16:15

    The string you see when running GDB really ends at the first null character:

    "\rtest\r18/04/2010\rtest2\r03/05/2010\rtest3\r05/08/2009\rtest4\r\n\000"
    

    The other data after is ignored (when using ordinary str-functions);

提交回复
热议问题