bug-glibc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: serious sscanf bug


From: Andreas Schwab
Subject: Re: serious sscanf bug
Date: Tue, 29 Apr 2003 11:49:42 +0200
User-agent: Gnus/5.090018 (Oort Gnus v0.18) Emacs/21.3.50 (gnu/linux)

Will Styles <address@hidden> writes:

|> program:
|> #include <stdio.h>
|> 
|> int main (void)
|> {
|>         int val;
|>         sscanf ("05", "%02i", &val);
|>         printf ("val = %i\n", val);
|> 
|>         sscanf ("06", "%02i", &val);
|>         printf ("val = %i\n", val);
|> 
|>         sscanf ("07", "%02i", &val);
|>         printf ("val = %i\n", val);
|> 
|>         sscanf ("08", "%02i", &val);
|>         printf ("val = %i\n", val);
|> 
|>         sscanf ("09", "%02i", &val);
|>         printf ("val = %i\n", val);
|> }
|> 
|> output:
|> val = 5
|> val = 6
|> val = 7
|> val = 0
|> val = 0

Correct.

|> what i should get:
|> val = 5
|> val = 6
|> val = 7
|> val = 8
|> val = 9

Wrong.  Look up %i in the manual.

Andreas.

-- 
Andreas Schwab, SuSE Labs, address@hidden
SuSE Linux AG, Deutschherrnstr. 15-19, D-90429 N├╝rnberg
Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."




reply via email to

[Prev in Thread] Current Thread [Next in Thread]