string pointer的问题
想把一个string赋值到new string返回的地址空间
string s1="hello,world";
string s2=new string;
for(unsigned int i=0;i<=s1.length();i++) s2[i]=s1[i];
编译ok,但运行error,好像是指向了非法地址,这是什么道理?
想把一个string赋值到new string返回的地址空间
string s1="hello,world";
string s2=new string;
for(unsigned int i=0;i<=s1.length();i++) s2[i]=s1[i];
编译ok,但运行error,好像是指向了非法地址,这是什么道理?
er.... resize(), at() function and C++ style string. I have checked some documents and I found that I confused char pointer and char array with string pointer and string. Thx HJin.