• 0

[C] How do I get around this warning message?


Question

When I attempt to compile in GCC on Linux, I get the following warning:

ISO C90 does not support the `%lf' printf format

The code in question is:

  Quote
void do_the_calculation(double a, double b, double c, double calculation, double root1, double root2)

{

  if (a != 0)

  {

printf("\nYou entered the numbers %lf, %lf, and %lf\n", a, b, c);

calculation = pow(b,2)-4*a*c;

printf("The discriminant of the quadratic equation is: %lf\n\n ", calculation);

root1 = (-b+(pow(b,2)-4*a*c))/(2*a);

root2 = (-b-(pow(b,2)-4*a*c))/(2*a);

printf("Roots are: %lf and %lf\n\n", root1, root2);

  }

  else

printf("Non-real answer will result if a = 0");

}

How can I get around this?

Obviously I want to printf a double. My lab instructor is picky and requires us to fix all warning messages. The odd part is that this error message only occurs on the Linux machines at my university, but compiling this program within Windows results in no errors.

Is this something Linux-specific, or is there actually something not right with my code? Please note this GCC compiler was modified to be VERY sensitive.

Thanks.

3 answers to this question

Recommended Posts

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.