【发布时间】:2020-02-18 13:20:41
【问题描述】:
我想用函数 printf 在 c Visual Studio 项目中打印■(ASCII 码 254),但我的程序无法打印。就像(?而不是■)
我的程序可以打印 ascii 字符 32 ~ 128。
我认为由于 129~254 是扩展 ascii,它需要更多的代码(头文件?其他功能?)。
如何打印■?请帮帮我。
这是我的代码。
#include<stdio.h>
int main() {
unsigned char count;
for (count = 32; count < 255; count++) {
printf(" %3d - %c", count, count);
if (count % 6 == 0) {
printf("\n");
}
}
return 0;
}
【问题讨论】:
-
在 Visual Studio 2019 上打印正常。您是否更改了项目中的任何配置?
-
检查您的控制台窗口设置为哪个代码页
-
不,我刚刚使用了 Microsoft Visual Studio 2019。并且代码没有变化
-
哦,我在控制台中使用韩语,所以无法打印 129~255。我通过添加 #include
和 system("chcp 437"); 解决了问题###### system("chcp 437") is change language of dos window(cmd) 谢谢! -
您可能希望使用
wchar_t和 wprintf。
标签: c printf extended-ascii