Home > Back-end >  C, how to use a single Chinese character on char types to initialize?
C, how to use a single Chinese character on char types to initialize?

Time:02-15

Int main (void)
{
cout <"Define a character array [], can use the array name a to output:";
Char a []="I love you".
cout
cout <"But can't use subscript to output a [2], otherwise, cout output gap:";
cout
cout <"Char variable cannot be initialized with a single Chinese character, otherwise, cout output gap:";
Char b='me';
cout
cout
cout <"Why is this? \ n ";

return 0;
}

CodePudding user response:

CodePudding user response:

Because both multi-byte character and wide characters, Chinese characters need to be more than 1 byte space can put down, the char type variable only 1 byte of space, not put,
Cout of responsible attitude, don't want to give you the code, so just blank, blank than the code look better,

CodePudding user response:

Thank you, thank you

CodePudding user response:

reference 1/f, the wise know already should good karma response:
thank you thank you

CodePudding user response:

refer to the second floor forever74 response:
because both multi-byte character and wide characters, Chinese characters need to be more than 1 byte space can put down, the char type variable only 1 byte of space, not put,
Cout of responsible attitude, don't want to give you the code, so just blank, blank than the code look better,

Thanks a lot

CodePudding user response:

The above said is truth! If use wchar, can, but pay attention to the front also want to add the L code strings

CodePudding user response:

refer to 6th floor 丁劲犇 response:
the above said is truth! If use wchar, can, but pay attention to in the code in front of the string will add L
thank you