|
-
Jan 5th, 2007, 03:53 PM
#1
Thread Starter
Frenzied Member
printf print values wrong??
Take the following printf code:
Code:
printf("%f %f %d",x(),y(),z());
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?
-
Jan 6th, 2007, 06:14 AM
#2
Hyperactive Member
Re: printf print values wrong??
Making a test using printf, I didn't see this issue at all. Using the same thing as you, my code:
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();
}
My output was correct though.
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.
If my post was helpful please rate it 
-
Jan 6th, 2007, 07:56 AM
#3
Thread Starter
Frenzied Member
Re: printf print values wrong??
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|