gcc floating point problem with scanf
Marold Moosrainer
marold.moosrainer@web.de
Sat Jun 30 09:52:00 GMT 2001
DearÃÂ cygwin team,
I cannot correctly input floating point numbers via scanf. I am using gcc
2.95.3-4 as it is distributed by cygnus solutions. My machine is a Pentium Win98
computer. Please find attached the requested cygcheck.out file and below a code
snip for the problem. I would be happy to get some ideas.
Regards, Marold
Command line:
$ gcc scanf_float.c
Source code:
#include <stdio.h>
int main(void) { ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ int
i; ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ float
flt; ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ double dbl;
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ printf("Enter int: "); ÃÂ ÃÂ ÃÂ /*
55 */ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ scanf("%i",
&i); ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ printf("i=%i\n",
i);ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ /* 55, ok
*/ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
printf("Enter float: "); ÃÂ ÃÂ ÃÂ /* 5.543
*/ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ scanf("%f",
&flt); ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ printf("flt=%f\n",
flt);ÃÂ ÃÂ ÃÂ /* 5543.000000, ERROR */
ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ printf("Enter double:
");ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ /* 5.543 */ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
scanf("%lf", &dbl); ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ printf("dbl=%f\n",
dbl);ÃÂ ÃÂ ÃÂ /* 5543.000000, ERROR
*/ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ ÃÂ
return 0; }
cygcheck.out
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cygcheck.out
Type: text/x-algol68
Size: 12128 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20010630/2a78f8ac/attachment.bin>
More information about the Cygwin
mailing list