#include<stdio.h>
void
main()
{
char
string[100]//定义一个数组存放你输入的字符串
scanf(string)//在键盘上输入中文,输入完回车就好
printf(“%s”string)//输出你输入的中文
}
1、中文字符串可以使用printf()、puts()等函数直接输出。#include <stdio.h>
#include <locale.h>
int main()
{
const char str[] = "这里全是中文"
printf("\n输出字符数:%d\n", printf(str))
puts(str)
return 0
}2、单个中文字符,需要进行本地化设置,需要使用宽字符版的printf()即wprintf输出。
#include <stdio.h>
#include <locale.h>
int main()
{
setlocale(LC_ALL, "chs")
wchar_t wc = L'中'
wprintf(L"%c\n",wc)
return 0
}