Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/124.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在C+中显示时使用单引号和双引号的不同答案+;_C++ - Fatal编程技术网

C++ 在C+中显示时使用单引号和双引号的不同答案+;

C++ 在C+中显示时使用单引号和双引号的不同答案+;,c++,C++,我在C++程序中用单引号显示了一条语句,我得到的答案是随机数,当我在C++中使用双引号时,它向我显示了该语句 cout << 'Hello world'; //gave me the random numbers cout << "Hello world"; //displayed me the statement i.e Hello world cout单引号用于字符: charc='A' 如果要打印一个多字符的字符串,请使用双引号: cout您正在尝试打印需要双引号

我在C++程序中用单引号显示了一条语句,我得到的答案是随机数,当我在C++中使用双引号时,它向我显示了该语句

cout << 'Hello world'; //gave me the random numbers
cout << "Hello world"; //displayed me the statement i.e Hello world

cout单引号用于字符:
charc='A'

如果要打印一个多字符的字符串,请使用双引号:

cout您正在尝试打印需要双引号的字符数组

char str[3] = "abc"; //an array of characters, use double quotes
str[0] = 'x';   //set a character in this array, use single quote

'表示单个字符,请使用“”表示字符串,您看到的随机内容是从该字符到第一个字符的计算机内存转储\0请看:这是一个多字符文本,请查看此帖子: