Hello,
I am using Code::Blocks 10.05.
Recently I tried writing a program which uses a double type.
The return wasn't as expected so I began debugging.
Finally I found out that I have problem with scanning a double type, even tried it in a different project to isolate the case, still doesn't work.
No matter what is the input, the print is always 0.0000...
Example code:
#include <stdio.h>
int main(){
double x;
scanf("%lf",&x);
printf("%lf",x);
return 0;
}
Any help would be much appreciated!
Best regards,
Oran
Are you sure your program is rebuild? Have you tried to change
to
printf("My number is:%lf",0.22);
And look if the output is correct
If your program is rebuild correctly and you still get the wrong number:
Your question has absolutely nothing to do with codeblocks. This question is C or Compiler related and this forum does not provide any support for either.
If your program does not get rebuild and you does not get the expected output:
http://wiki.codeblocks.org/index.php?title=FAQ-Compiling_(general)#Q:_How_do_I_report_a_compilation_problem_on_the_forums.3F
Not related to your question: Codeblocks 10.05 is soooooooooo old. I would update
[edit:] are you sure you enter the number correctly with the correct coma separator for your language/terminal
You need to find an C/C++ support website for your compiler.
Find out all the information about your compiler you are using, before posting on it.
printf("My number is:%f",0.22);
You compiler likely does NOT support "lf"; in the printf statements this is common with old compilers!
I suggest signing up for help on https://cboard.cprogramming.com/forum.php (https://cboard.cprogramming.com/forum.php) it can take a few days for the signup to be approved.
Tim S.