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.
By the way I am using uCLinux (dist 20060803) with kernel 2.4 and uClibc
for a Coldfire processor.
Thanks for your help
Mathias
_______________________________________________
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