This is the mail archive of the
ecos-devel@sourceware.org
mailing list for the eCos project.
Bug in fprintf/fscanf
- From: Martin Laabs <martin dot laabs at mailbox dot tu-dresden dot de>
- To: ecos-devel at sources dot redhat dot com
- Date: Wed, 16 Mar 2011 22:08:52 +0100
- Subject: Bug in fprintf/fscanf
- Reply-to: uni at martinlaabs dot de
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