一个C语言的小程序有点小问题不解
void ConvertPicturePathFormat(std::string *strPath)
{
int nStringLength = strPath->length();
char *src = (char *) malloc (sizeof(char)*nStringLength + 1);
strcpy(src,strPath->c_str());
src[nStringLength] = '\0';
// we create a buffer that is twice bigger than the src buffer.
char *des = (char *)malloc(sizeof(char)*nStringLength*2);
memset(des,0,sizeof(des));
for (int i = 0,j = 0; i < nStringLength; i++,j++)
{
if (src[i] != '\\')
{
des[j] = src[i];//2. 从1 运行到这里后,des在调试窗口中的值为无效,为啥?
continue;
}
else
{
des[j] = '\\';
j++;
des[j] = '\\';//1. 运行到这里后,des后面没有被赋值的部分变成了"屯屯屯.."
}
}
}