BOOL IsInDays(int day,string monthdays) { char *tmp = new char[3]; memset(tmp,0,sizeof(char)*3); itoa(day,tmp,10); int len = strlen(monthdays.c_str())+1; char *days = new char[len]; memset(days,0,len); strcpy_s(days,len,monthdays.c_str()); char *c_strDay; char **p = &days; c_strDay = strsep(p, ","); while(c_strDay) { if (strcmp(c_strDay,tmp)==0) { p = 0; delete [] days; days = NULL; delete []tmp; tmp = NULL; return TRUE; } c_strDay = strsep(p, ","); } p=0; delete [] days; days = NULL; delete []tmp; tmp = NULL; return FALSE; }
我编译delete是没有问题的。而且你的delete释放内存句法是没有问题的。int *pt = new int; delete pt即可。int *ps = new int [10],释放内存就用delete [] ps;这是正确的。你再看看其他问题吧
delete days;
这样试试
数组是不能这样删除的
@IT Giant:那用FREE吧