![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| how to make a line BLINKING in output and also how to increase font size in output | mail2sant | Shell Programming and Scripting | 3 | 04-14-2008 04:30 AM |
| Why I don't get any output? | Sharmin | High Level Programming | 6 | 09-17-2006 09:34 AM |
| awk output? | kion | Shell Programming and Scripting | 6 | 02-11-2005 08:56 PM |
| FTP Output | lindeng | UNIX for Dummies Questions & Answers | 9 | 02-10-2004 07:18 PM |
| Deleting a File with an Erroneous Period | PLF | UNIX for Dummies Questions & Answers | 3 | 08-08-2001 11:04 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
erroneous output
#include<stdio.h>
int main () { FILE* f_read; FILE* f_write; char *string[80]; f_read=fopen("file1","r"); while(!feof(f_read)); { fscanf(f_read,"%s",string); fprintf(stdout,"%s\n",string); } return 0; } INPUT FILE ___________ manu jilu ruta OUTPUT ----------- manu jilu ruta ruta why the last line is being read two times |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
You are not error checking the return from your fscanf()
|
|
#3
|
||||
|
||||
|
It isn't being read twice, it is being written(printed) twice. As porter has suggested, check the return value on your fscanf and exit if it is EOF.
|
||||
| Google The UNIX and Linux Forums |