Today I decided to recap a bit the C programming language fundamentals and I have encountered this small issue within my Code::Blocks IDE: when I had used the %f
format identifier to read and write a decimal number everything went well, but when I had switched to the %lf
format identifier, it did not read or write the number properly.
This is my code:
#include <stdio.h>
int main()
{
double x;
scanf("%lf", &x);
printf("x = %lf", x);
return 0;
}
These are the compiler settings from the Code::Blocks menu:
I have searched for a solution online, including the Code::Blocks forums, but I haven't found anything relevant. I am not sure whether is a compiler problem or an IDE problem. If you know a fix or you have an explanation for this issue, please help me. I am preety sure other people encountered this as well.