Take the following printf code:
Why would printf print the y() value first and the x() value second I listed them in the correct order? Is this a bug in gcc?Code:printf("%f %f %d",x(),y(),z());
Printable View
Take the following printf code:
Why would printf print the y() value first and the x() value second I listed them in the correct order? Is this a bug in gcc?Code:printf("%f %f %d",x(),y(),z());
Making a test using printf, I didn't see this issue at all. Using the same thing as you, my code:
My output was correct though.Code:#include <iostream>
#include <conio.h>
float x();
float y();
int z();
float x() { return 12.00; }
float y() { return 34.00; }
int z() { return 1234; }
int main()
{
printf( "%f %f %d", x(), y(), z() );
_getch();
}
The only thing I could see causing it to not return correctly is that you are mixing up the functions somewhere in the code. As in x is being given the value of y, and y being given the value of x somewhere. Double check that the code is correct and each function is being given the correct value in the end result before attempting to print it out.Quote:
12.000000 34.000000 1234
Thanks. That is exactly what I thought. This question was posed at another forum and didn't make sense for printf to give wrong output like that. There are logical errors why, but don't think it's a bug.