scanf to handle double
- From: "Red Dragon" <tskhoon@xxxxxxxxxxxx>
- Date: Thu, 3 Nov 2005 10:21:57 +0800
Can someone please tell me how I should write scanf to handle double?
This program works fine for float a but not double a, as the print result
at end of program illustrates.
Thanks
Khoon
#include <stdio.h>
int main (void)
{
double a;
a =2.1111;
printf ("Enter a> ");
scanf ("%f", &a);
printf ("a=%4.4f\n",a);
return 0;
}
/*
Result:
Enter a> 555.55
a=2.1111
Press any key to continue
*/
.
- Follow-Ups:
- Re: scanf to handle double
- From: Mike Wahler
- Re: scanf to handle double
- Prev by Date: Re: variable sized unions
- Next by Date: Re: [OT] Re: computer programming
- Previous by thread: variable sized unions
- Next by thread: Re: scanf to handle double
- Index(es):
Relevant Pages
|