hi there, im currently a student studying games programming at university, and i have applied for aplacemnt at a company over the summer. for this placement i have been given a code test but i am having trouble with one of the aspects with it. we havent been set any specific guidelines and its our approach to the problem they are looking at more - so i dont think this is cheating the problem is as shown below:
now, i have put the code into my compiler and i dont get '0' printed. i have looked at it and the 'Max' function does return the correct value, so the problem is elsewhere, i just cant see it. any help would be much appreciated. cheers.
This C++ programmer heard that the max() macro was dangerous so he opted for the relative safety of an inline max() function. So why is 0 printed?
#include <stdio.h>
typedef unsigned short Word;
inline int
Max( int n, int m)
{
return n>m ? n : m;
}
Word w1=40000,w2 = 0;
int
main()
{
printf( “%d\nâ€, Max( w1, w2) );
return 0;
}
now, i have put the code into my compiler and i dont get '0' printed. i have looked at it and the 'Max' function does return the correct value, so the problem is elsewhere, i just cant see it. any help would be much appreciated. cheers.