Pik*_*ppa 1 c file function stream
我有这个功能:
void aggiornadatabase(void) {
FILE* fp;
int c=0;
char str[30];
int m;
sprintf(str, "%s.csv", utenti[posizioneuser].id);
printf("%s\n", str);
fp = fopen(str, "w");
if (fp == NULL)
printf("Database error\n");
else
m = remove(str);
if (m == 0)
printf("Success\n");
else
printf("Unable to delete the File\n");
fclose(fp);
}
Run Code Online (Sandbox Code Playgroud)
执行此函数时,它会删除所选.csv文件中的所有内容,但它不会删除文件本身(实际上它会打印"无法删除文件").
为什么会这样?