64,682
社区成员
发帖
与我相关
我的任务
分享
//C-style character string
const char *pc="a very long literal string";
const size_t len=strlen(pc);
for(size_t ix = 0;ix != 1000000;++ix)
{
char *pc2=new char[len + 1];
strcpy(pc2,pc);
if(strcmp(pc2,pc))
;
delete []pc2;
}
//string class
string str("a very long literal string");
for(int ix = 0;ix != 1000000;++ix)
{
string str2=str;
if(str != str2)
;
}
int n=0;
printf("n:");
scanf_s("%d",&n);
int **p = new int*[n];
for(int i=0; i<n; i++)p[i]=new int[n];
......
for(int i=0; i<n; i++)delete p[i];
delete []p;
for(size_t ix = 0;ix != 1000000;++ix)
{
char *pc2=new char[len + 1];
strcpy(pc2,pc);
if(strcmp(pc2,pc))
;
delete []pc2;//这里为什么不是delete pc2;
}