【发布时间】:2020-05-16 09:53:53
【问题描述】:
我不知道为什么这个函数会导致堆损坏,我确定函数 copyFile 与错误无关。请检查并帮助我TT
void copyFileToFolder(char* fileName, char* folderName)
{
char backSlash = '\\';
char *nameOfFileWithBackSlashInHead = strrchr(fileName, backSlash);
char *newFileName = strcat(folderName, nameOfFileWithBackSlashInHead);
FILE* f = fopen(newFileName, "wb");
if (!f)
{
cout << "Folder does't exist";
return;
}
fclose(f);
copyFile(fileName, newFileName);
}
【问题讨论】:
-
P/S:尽管堆损坏,程序仍然可以工作
标签: c++ string heap-corruption