The problem is &cursorTile.Attributes.
The error I am getting is (argument of type "WORD*" is incompatible with parameter of type "LPCWSTR")
I have tried to find some solutions, I am using multi-byte character set.
void CMap::Draw(){
SMALL_RECT drawRect = { 0, 0, MAP_WIDTH - 1, MAP_HEIGHT - 1 };
COORD buffersize = { MAP_WIDTH, MAP_HEIGHT };
COORD zeroZero = { 0, 0 };
DWORD dwResult = 0;
char szCursor[2] = "";
HANDLE hOutput = GetStdHandle(STD_OUTPUT_HANDLE);
for (int i = 0; i < (int)m_vTiles.size(); i++){
m_screenBuffer[i] = m_vTiles[i].GetChar();
}
WriteConsoleOutput(hOutput, m_screenBuffer, buffersize, zeroZero, &drawRect);
if (g_pCursorTile != NULL){
CHAR_INFO cursorTile = g_pCursorTile->GetChar();
sprintf(szCursor, "%c", cursorTile.Char);
WriteConsoleOutputCharacter(hOutput, szCursor, 1, g_cursorPos, &dwResult);
WriteConsoleOutputCharacter(hOutput, &cursorTile.Attributes, 1, g_cursorPos, &dwResult);
}
this is very explenetory error.
WriteConsoleOutputCharacter
expects some string as the second argument. if your program is defined as unicode, it expectsLPCWSTR
, which is basically an (ugly) type-definition to a null terminatedwchar_t*
string.in your invocation, you pass
&cursorTile.Attributes
which has the type ofDWORD*
(which is again, ugly type-definition tounsigned long*
). you need to pass some wide-char string instead of unsigned long pointer, which is , the string you are trying to print.