Invalid output with fscanf() <p>The language I am using is C I am trying to scan data from a file, and the code segment is like:</p> <pre><code>char lsm; long unsigned int address; int objsize; while(fscanf(mem_trace,"%c %lx,%d\n",&amp;lsm,&amp;address,&amp;objsize)!=EOF){ printf("%c %lx %d\n",lsm,address,objsize); } </code></pre> <p>The file which I read from has the first line as follows:</p> <pre><code> S 00600aa0,1 I 004005b6,5 I 004005bb,5 I 004005c0,5 S 7ff000398,8 </code></pre> <p>The results that show in stdout is:</p> <pre><code> 8048350 134524916 S 600aa0 1 I 4005b6 5 I 4005bb 5 I 4005c0 5 S 7ff000398,8 </code></pre> <p>Obviously, the results had an extra line which comes nowhere.Is there anybody know how this could happen? Thx!</p>