public inbox for
 help / color / mirror / Atom feed
* Bug in fprintf/fscanf
@ 2011-03-16 21:09 Martin Laabs
  0 siblings, 0 replies; only message in thread
From: Martin Laabs @ 2011-03-16 21:09 UTC (permalink / raw)
  To: ecos-devel


could someone please verify the following bug I discovered. It seems that 
fprintf (or fputs) fails after a fscanf call. The second fprintf call 
however does work as expected.
I currently use the network as stream. Maybe this bug is because I use the 
fdopen function but at the moment I do not have an other working file 

Follwoing Code:

    term=fdopen(clntSock, "r+");

	  fprintf(term, "Type a number\n");
	  diag_printf("fscanf %d\n", fscanf(term, "%d",&num));
	  diag_printf("fprintf1 %d\n",fprintf(term, "Number was %d\n",num));
   	  diag_printf("fprintf2 %d\n",fprintf(term, "Again - Number was 

Produces following output (with Input of 8, 9 and 10):

Type a number
Again - Number was 8
Type a number
Again - Number was 9
Type a number
Again - Number was 10
Type a number

With diag output of:

fscanf 1
fprintf1 0
fprintf2 21
fscanf 1
fprintf1 0
fprintf2 21
fscanf 1
fprintf1 0
fprintf2 22

The complete code is available under


  Martin Laabs

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2011-03-16 21:09 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-16 21:09 Bug in fprintf/fscanf Martin Laabs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).