I'm working on a poker game in c++ using Visual Studio Express 2013 on Windows 10. When i use the following code to assign suits to my cards the console displays all question marks in the place of the suits.
void printHand(Card hand[])
{
const string SUIT = "\3\4\5\6";
const string RANK = "23456789TJQKA";
cout << "Your hand is: ";
for (int i = 0; i < SIZE; i++)
{
cout << RANK[hand[i].ranks] << SUIT[hand[i].suits] << " ";
}
cout << endl;
}
When I change the suits to other characters I get the right characters like question marks, colons... When I run a for loop to show all Ascii characters, the first 32 characters display as control characters like it doesn't recognize the font.
My question is whether this is because of Visual Studio 2013 Express, Windows 10, or my machine.
Check the checkbox in Properties that says "Use the old console" or something like that (Mine was in swedish). That solved the problem for me.
There are a number of things you must check:
- Make sure your console is using Code Page 437
- Failing that, make sure your program's locale is the default "C" locale.
Let us know if it still doesn't work.
来源:https://stackoverflow.com/questions/33534895/ascii-heart-in-c-windows-10-not-displaying