Can anyone tell me how to delete a file in the same folder as the .exe file?
Thanks for your help!
-KaibaFan321
Printable View
Can anyone tell me how to delete a file in the same folder as the .exe file?
Thanks for your help!
-KaibaFan321
Tutorial on File I/O
[edit] It's Under Useful Functions [/edit]
Quote:
Originally Posted by KaibaFan321
Code:int main(int argc, char ** argv) {
int error, status = 0;
const char * errname = 0;
while(*(++argv)) {
printf("Deleting '%s'...", *argv);
error = remove(*argv);
if(error) {
status = error;
errname = "Failed";
} else {
errname = "Success";
}
printf("%s (%d).\n", errname, error);
}
return status;
}
>>error = remove(*argv);
>>status = error;
>>return status;
A minor point, but be warned that you could be returning undefined values, as remove() will return non-zero on error.