Home > Back-end >  Vscode input the scanf read in Chinese, the result error
Vscode input the scanf read in Chinese, the result error

Time:12-05

IDE for vscode, use the scanf input Chinese characters, use the print output is empty or 00, why?

 # include & lt; stdio.h> 

Int main () {
Char name [20].
The scanf (" % s ", name);
Printf (" % s \ n ", name);
return 0;
}


CodePudding user response:

#include
#include

Int main () {
Char name [20].
CHCP system (" 65001 ");//CHCP 936
The scanf (" % s ", name);
Printf (" % s \ n ", name);
return 0;
}

CodePudding user response:

reference 1/f, zhao teacher reply:
# include & lt; stdio.h>
#include

Int main () {
Char name [20].
CHCP system (" 65001 ");//CHCP 936
The scanf (" % s ", name);
Printf (" % s \ n ", name);
return 0;
}


No same uowu terminal before and I have set 65001 for direct use printf output Chinese normal display
Now only use the scanf reads Chinese output is not output empty

Printf (" % d ", the scanf (" % s ", name));
And I also confirmed the scanf the return value is 1, which is read in the string
But it is unclear when read in a string is an empty string or output, it may even be related to vscode environment

CodePudding user response:

well,,,

CodePudding user response:

My CHCP is 936, corresponding to GB2312

CodePudding user response:

refer to 6th floor a white steamed bun response:
my CHCP is 936, corresponding to the GB2312


Brother, you are right I all files and terminal set before 65001 can normal output Chinese utf-8, but you can't input the reason I don't know
Now all the original file and terminal change to 936 GB2312 can either type in Chinese and the output of Chinese thanks!
  • Related