我想在 visual studio (c++) 中打印这个特殊字符 █ 但我得到“?” . 我写的对应代码:
bool b[5][3] = { { true,true,true },{ true,false,true },{ true,false,true },
{ true,false,true },{ true,true,true } };
system("color 0A");
for (int i = 0; i < 5; i++)
{
for (int j = 0; j < 3; j++)
{
if (b[i][j])
{
gotoXY(3 + j, 5 + i);
cout << "█";
}
}
cout << endl;
}
你应该使用宽输出:
#include <iostream>
#include <stdio.h>
#include <fcntl.h>
#include <io.h>
int main()
{
::_setmode(::_fileno(stdout), _O_U16TEXT);
::std::wcout << L"█" << ::std::flush;
return 0;
}
此外,如果您打算使用伪图形,那么您可能需要为控制台选择一些像素字体,以便在没有抗锯齿和间隙的情况下呈现符号。