Author Topic: Compiler Bug? C99-Standard  (Read 11331 times)

marceljb

  • Guest
Compiler Bug? C99-Standard
« on: November 09, 2011, 07:36:00 pm »
Hey everybody
I'm using C::B 10.05 with GCC-Compiler (rev. 6283) under windows 7(64).

int main()
{
    double z;
    printf("Input: "); //input e.g. 5
    scanf("%lf", &z);
    printf("Your input: %lf", z); //!!!output 0.000000, after deactivating C99-Standard z==5.000000!!!

    return 0;
}


Is there a solution for this issue?
THX


zabzonk

  • Guest
Re: Compiler Bug? C99-Standard
« Reply #1 on: November 09, 2011, 07:49:33 pm »
The problem (if it is a problem) is with GCC, not with Code::Blocks - you get the same behaviour on the command line. I should point out that there is no "%lf" conversion specification for printf - printf only deals with doubles and the conversion specification is "%f" , because floats are automatically converted to doubles when they are variadic parameter values. Note that the set of conversion specifications used by printf does not have a one-to-one correspondence with those used by scanf.  Maybe C99 has tightened this up, or changed it in some way - I'm not a C99 expert. You want to ask about this somewhere like StackOverflow.
« Last Edit: November 09, 2011, 07:51:24 pm by Neil Butterworth »