Search code examples
cdoublescanflf

scanf reads every double wrong


I have the following code:

    int main(void)
{
    double r;
    scanf("lf",&r);
    printf("%lf\n",r);
}

Any value I enter returns a nonsense-number with about 40-50 digits. scanf works fine with chars, integers, strings etc., but with doubles I get this problem. Can anybody help me?


Solution

  • scanf("lf",&r);
    

    Should be

    scanf("%lf",&r);