public inbox for ecos-devel@sourceware.org
 help / color / mirror / Atom feed
From: Martin Laabs <martin.laabs@mailbox.tu-dresden.de>
To: ecos-devel@sources.redhat.com
Subject: Bug in fprintf/fscanf
Date: Wed, 16 Mar 2011 21:09:00 -0000	[thread overview]
Message-ID: <4D8126E4.2090101@mailbox.tu-dresden.de> (raw)

Hello,

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 
descriptor.


Follwoing Code:

    term=fdopen(clntSock, "r+");
    assert(term!=0);

    while(1)
	{
	  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 
%d\n",num));
	}

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

Type a number
8
Again - Number was 8
Type a number
9
Again - Number was 9
Type a number
10
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 http://pastebin.com/8iYVkAhz

Greetings,

  Martin Laabs

                 reply	other threads:[~2011-03-16 21:09 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4D8126E4.2090101@mailbox.tu-dresden.de \
    --to=martin.laabs@mailbox.tu-dresden.de \
    --cc=ecos-devel@sources.redhat.com \
    --cc=uni@martinlaabs.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).