33,311
社区成员
发帖
与我相关
我的任务
分享
#include<string.h>
#include<iostream.h>
using namespace std;
int main()
{
char *str=NULL;
//char *str1="hello"
str=new char[100];
strcpy(str,"hello");
delete []str;
cout<<str<<endl;
if(str != NULL)
{
strcpy(str,"world!");
printf(str);
}
cout<<"ni hao"<<endl;
system("pause");
}
delete[] str;
str = NULL;//习惯性动作
//否则str野指针