Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Contributions to C::B => Topic started by: marceljb on November 09, 2011, 07:36:00 pm

Title: Compiler Bug? C99-Standard
Post by: marceljb 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

Title: Re: Compiler Bug? C99-Standard
Post by: zabzonk 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.