如何在C语言中输出中文!

2025-03-13 19:53:34
推荐回答(1个)
回答1:

1、
中文
字符串
可以使用printf()、puts()等
函数
直接输出。
#include
#include
int main()
{
const char str[] = "这里全是中文";
printf("\n输出字符数:%d\n", printf(str));
puts(str);
return 0;
}
2、单个中文字符,需要进行本地化设置,需要使用宽字符版的printf()即wprintf输出。
#include
#include
int main()
{
setlocale(LC_ALL, "chs");
wchar_t wc = L'中';
wprintf(L"%c\n",wc);
return 0;
}