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