64,680
社区成员
发帖
与我相关
我的任务
分享
#include <iostream.h>
#include <iostream.h>
void main()
{
int i;
char str[] = "abc";
char *ps = "def"; //这样ps是指向常量区的指针,数据不能修改,改成char *ps = new char[4];
for (i = 0;i < 3;i++)
{ temp = str[i];
str[i] = *(ps + i);
*(ps + i) = temp;
}
cout < <str < <endl;
cout < <ps < <endl;
}