Hi there, I'm trying to learn WinAPI but I don't understand how I can print variables with TextOut(), I get the following error:
error C2664: 'TextOutW' : cannot convert parameter 4 from 'int' to 'LPCWSTR'
sprintf works with char arrays, not TCHAR or WCHAR arrays.
If you are trying to be unicode friendly (you should), and if you must use sprintf, then specifically use the ANSI version of TextOut (ie: TextOutA)
1 2 3 4 5 6 7 8
int number = 5;
char mybuffer[10]; // make sure it's big enough -- buffer overflow = bad
sprintf(mybuffer,"%d",number);
// note again: TextOutA, not TextOut
TextOutA(hdc,10,10,mybuffer, strlen(mybuffer) );
For more info on being Unicode friendly in WinAPI, see this: