|
From: Per W. <pw...@ia...> - 2006-02-24 10:13:09
|
No, you can't use an old c++ manual (or actually C manual).
It must be a broken manual.
The runtime library must know the physical size of the variable to be able
to initialize it.
For printf() you send a value. The standard says that functions without a
prototype - or variadric functions - should have the variables upgraded
from float to double on call. This makes printf() support float and
double.
However, scanf() doesn't take a float our double. It takes a pointer to a
float or double. To perform the assign - it has to look at the
"formatting" parameter to decide what it should assign to.
%f specifies float
%lf specifies double
%Lf specifies long double (when supported)
/Per W
On Thu, 23 Feb 2006, Titi Anggono wrote:
> Hi all,
>
> I tried the following code
> ============================
> #include <stdio.h>
> #include <stdlib.h>
> #include <conio.h>
>
> main(){
> double a,b;
> scanf("%f",&a);
> printf("\n");
> scanf("%f",&b);
> printf("\n\n%f %f",a,b);
> getch();
> exit(EXIT_SUCCESS);
> }
> ==============================
> I enter any numbers and the output is
> 0.0000 0.00000
> but, when I change the "double" with "float", the code
> gives me the right answer.
>
> Is there any explanation why I can't use "double" with
> "%f" in dev-cpp ? Maybe I use old c++ manual lol. How
> can I print the "double" number ?
>
> Titi
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by xPML, a groundbreaking scripting language
> that extends applications into web and mobile media. Attend the live webcast
> and join the prime developer group breaking into this new coding territory!
> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
> _______________________________________________
> Dev-cpp-users mailing list
> Dev...@li...
> TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm
> https://lists.sourceforge.net/lists/listinfo/dev-cpp-users
>
|