Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.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++_String_Char - Fatal编程技术网

C++ C+中的字符数组+;

C++ C+中的字符数组+;,c++,string,char,C++,String,Char,为什么,当我有以下代码时,我可以明确地说coutstd::ostream&operator,因为operatorSo,你的问题是什么?注意new是坏的:char a[]=“foo”@chris:No,std::string a=“foo”@LightnessRacesinOrbit,完全正确。我从来没有想过。没有定义的行为有多少? char * a; a=new char [5]; strcpy(a,"foo"); cout << a; #include <iostream&

为什么,当我有以下代码时,我可以明确地说
cout
std::ostream&operator,因为
operatorSo,你的问题是什么?注意
new
是坏的:
char a[]=“foo”@chris:No,
std::string a=“foo”@LightnessRacesinOrbit,完全正确。我从来没有想过。没有定义的行为有多少?
char * a;
a=new char [5];
strcpy(a,"foo");
cout << a;
#include <iostream>

int main()
{
  char word[] = {'a', 'b', 'c'};
  int n = 42; // some non-zero data
  std::cout << word << std::endl;
}