注册 登录
编程论坛 C++教室

请教字符串指针的问题

mgp1030 发布于 2007-02-13 13:10, 429 次点击


#include <iostream>
#include <cstring>
using namespace std;

int main(){
char* p = "abc";
//*p +1 = 'd';
char* t = new char[strlen(p)+1];
*t = "werdsf";//为什么不能赋值?
cout<<t<<endl;
return 0;
}

2 回复
#2
踏魔狼2007-02-13 19:27
*t 这样就不是一个指针啦.
把*去掉.
#3
bluesky13222007-02-21 22:40
楼上的正解
1