Ok, I have taken a year of Computer Science at a University. However, we did not have time for graphics before we left for the summer. I am expiramenting on my own and have hit a question.
I can display text:
TextOut(hdc, 150, 750, TEXT("Player 1:"),9);
I have not been able to figure out how to display a variable such as:
1 2
int score = 0;
TextOut(hdc, 150, 750, score,1);
I have read some other posts and tutorials but I cannot seem to get a simple sample code. I am guessing it looks something like this but I cannot get it to compile or understand what it does...
1 2 3
char buf[ BUFFER_SIZE ];
TextOut( hdc, x, y, buf, wsprintf( buf, "The number is %d.", score ));
// compile error: error C2664: 'TextOutW' : cannot convert parameter 4 //from 'char' to 'LPCWSTR'
TCHAR is a macro, if UNICODE is defined TCHAR is a WCHAR, else it is a char.
TEXT() is also a macro, it prepends an L if needed to the string literal passed to it, So TEXT("Total Guesses:" ) wil become either L"Total Guesses:" or "Total Guesses:" depending on if UNICODE is defined or not.
Most of the Windows API has a macro defined to decide what the required function is, e.g. MessageBox is replaced with either MessageBoxA or MessageBoxW, so using macros like TCHAR and TEXT(), will make sure the correct parameter types are used.