c语言中如何打出中文?

Python014

c语言中如何打出中文?,第1张

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

}

1、首先新建一个dev C++的项目。

2、接下来在项目中新建C语言程序文件,如下图所示。

3、然后在C语言文件中声明一个字节数组。

4、接下通过printf函数提示用户输入字符串,通过scanf接收用户输入的字符串。

5、接着在通过printf函数输出用户输入的内容。

6、最后运行C语言程序,输入内容以后就存入字符数组了。