Am Dienstag, den 13.02.2007, 16:43 +0100 schrieb
[EMAIL PROTECTED]:
>
> Hi Developpers,
>
> I'm sorry, but i have to post my problem again:
> I've a problem using "sscanf" but it is the same with using
> atof, strtof or something else.
>
> The problem is, that it seems that sscanf doesn't check the
> range of the var to which the digits should be converted.
> So here is my example:
> unsigned int output;
> char input1[] = "9999999999\0";
> char input2[] = "999999999\0";
> if (sscanf(input1, "%d", &output) != 1)
> {
> printf("sscanf returned an error for input 1\n");
> exit(0);
> }
> printf("we read %d for input 1\n", output);
> if (sscanf(input2, "%d", &output) != 1)
> {
> printf("sscanf returned an error for input 2\n");
> exit(0);
> }
> printf("we read %d for input 2\n", output);
> exit(0);
>
> The output is:
> we read 1410065407 for input 1
> we read 999999999 for input 2
>
> In the first case, sscanf doesn't work fine. The problem is, that
> the
> maximum integer is 0xffffffff whis is 4294967295. So, my input is
> bigger than the maximum value.
> I thought, that in this case, sscanf should set the &ouput
> to INFINITY. Or, at least, it should return 0. But it looks like
> sscanf
> just returns a meaningless value.
Hi Mathias,
why don't you like the idea that I suggested a while ago to set errno=0
before calling sscanf and check the value of errno afterwards?
Regards,
Erwin
_______________________________________________
uClinux-dev mailing list
[email protected]
http://mailman.uclinux.org/mailman/listinfo/uclinux-dev
This message was resent by [email protected]
To unsubscribe see:
http://mailman.uclinux.org/mailman/options/uclinux-dev