ascii heart in c++ windows 10 not displaying

江枫思渺然 提交于 2019-12-02 02:26:15

问题


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.


回答1:


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.




回答2:


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!