marvel
سه شنبه 05 دی 1385, 14:22 عصر
سلام
به نظر شما متغیر achData در این کد را کجا باید delete کرد؟
char* achData=new char[100];//where do delete this pointer?
strcpy(achData,"Hello");//this pointer must initialize out of loop
for(;;)
{
char *ch=new char[100];
strcat(ch,achData);
if(ch)
{
delete[] ch;
ch=NULL;
}
}
if(achData)//This code will not run never
{
delete[] achData;
achData=NULL;
}
به نظر شما متغیر achData در این کد را کجا باید delete کرد؟
char* achData=new char[100];//where do delete this pointer?
strcpy(achData,"Hello");//this pointer must initialize out of loop
for(;;)
{
char *ch=new char[100];
strcat(ch,achData);
if(ch)
{
delete[] ch;
ch=NULL;
}
}
if(achData)//This code will not run never
{
delete[] achData;
achData=NULL;
}