bug-glibc
[Top][All Lists]
Advanced

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

Re: serious sscanf bug


From: Will Styles
Subject: Re: serious sscanf bug
Date: Wed, 30 Apr 2003 04:02:12 -0700 (PDT)

--- Andreas Schwab <address@hidden> wrote:
> 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.
> 
ok, i feel stupid now - trying to read in octals :)
i always thought that %i == %d.
so this bug should be closed (if it isn't already).

i'm just wondering though: should it be "%02d" or
"%2d" or "%d" to read in an integer padded with up to
2 zeros or is that printf syntax only?

thanks
- will

__________________________________
Do you Yahoo!?
The New Yahoo! Search - Faster. Easier. Bingo.
http://search.yahoo.com




reply via email to

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