current position:Home>How to capture and store a Chinese character in C language?

How to capture and store a Chinese character in C language?

2022-01-27 03:16:36 CSDN Q & A

As the title
Want to use scanf perhaps getchar Capture a Chinese character on the keyboard and store , What can I do




Refer to the answer 1:

char str[2];
scanf("%s",&str);

str Chinese characters can be stored in




Refer to the answer 2:



Refer to the answer 3:

scanf("%s",&str);
One of the Chinese characters accounts for 2 Bytes (GBK code ), that str[0],str[1] Together form a Chinese character , If more than one Chinese character is offset according to this rule




Refer to the answer 4:

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270316349103.html

Random recommended