#Help with C !
As a second attempt at C programming I tried the following:
#include <stdio.h>
main () {
float real;
printf("Enter a float number: ");
scanf("%f", &real);
printf("Float: %f\n", real); }
The result is:
Enter a float number: 3.1 Float: 2.137500
Why in the world does this happen? This does not occur when an
integer is used (changing %f to %d) and when I set real=constant the
correct constant is output. I presume there is something wrong with
the way I use scanf and floats. I am using SAS C with an A3000. Would
a compiler option do this?