【问题标题】:How can I print ■ in visual studio c?如何在visual studio c 中打印■?
【发布时间】: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


【解决方案1】:

我刚刚通过添加 system("chcp 437") 解决了,它在 cmd(dos 窗口) 中将语言韩语更改为英语。

这是我的代码

#include<stdio.h>
#include<Windows.h>
int main() {
    unsigned char count;
    system("chcp 437");
    for (count = 32; count < 255; count++) {
        printf("  %3d - %c", count, count);
        if (count % 6 == 0) {
            printf("\n");
        }
    }
    return 0;
}

【讨论】:

    猜你喜欢
    • 2021-05-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-10-10
    • 2014-11-08
    相关资源
    最近更新 更多