length 是字符长度,如"666"长度为3,但是直接new char[3],然后sprintf把666存进去,在delete[]的时候会卡住,new char[3+1]才行。char*类型经常容易忽略'\0'的存在
unsigned length = 0;
int temp = i+1;
while(temp != 0){
temp/=10;
++length;
}
char* digit = new char[length+1];//把'\0'算进去
sprintf(digit,"%d",i+1);
string faceName =(string)"面."+digit;
//string faceName = body+"|面."+digit;
delete[] digit;