Mail Archives: djgpp/1997/06/17/04:49:50
matteotti carlo wrote:
>
> I'm a beginner with C++ and I just started with DJGPP.
> As a little exercise I've written a stupid little "program" which
> should read a "real number" as a long double and write this number
> back to the screen again. But what I get back is just "-NaN".
> How can I convince the program that e.g. 1.13245 is indeed a number ??
Can you post sample code? Specifically, how are you declaring the
variable, how are you passing it to scanf(), and how are you printing
it? Here's an example:
#include <stdio.h>
int main( void )
{
long double ld;
printf( "Enter a decimal number: " );
if ( scanf( "%Lf", &ld ) == 1 )
printf( "You entered %Lf.\n", ld );
else
printf( "That's not a number.\n" );
return 0;
}
P.S.: Please post general programming questions on comp.lang.c or
comp.lang.c.moderated, or get a good C reference book.
hth
--
---------------------------------------------------------------------
| John M. Aldrich | "Sex should be friendly. Otherwise |
| aka Fighteer I | stick to mechanical toys; it's more |
| mailto:fighteer AT cs DOT com | sanitary." |
| http://www.cs.com/fighteer | - Lazarus Long |
---------------------------------------------------------------------
- Raw text -