I have this function:
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);
}
When this function executes, it deletes everything in the selected .csv file, but it does not delete the file itself (and indeed it prints "Unable to delete the File").
Why this is happening?