remove() function.

09/12/2012 16:07 syndrah#1
Hey guys.

I am attempting to create a function with deleting commands.

PHP Code:
void DELGG(){
remove("GameGuard\npgg.erl");
remove("GameGuard\npgl.erl");
remove("GameGuard\npgm.erl");
remove("GameGuard\npgmup.erl");
remove("GameGuard\npsc.erl");

i have it placed in attaching and detaching and set it for when my main function executes.

the problem is it doesnt delete. could it be that i have no writing access to those files. i dont think it would be this. any ideas is invited.
09/12/2012 21:26 MrSm!th#2
Where did you find that remove() function?
09/13/2012 06:24 syndrah#3
as in what sense?

#include "stdio.h" is where it comes from.
09/16/2012 18:36 tnd0#4
"i dont know why it doesnt work but im way too stupid to check for the errors these functions might return"
09/17/2012 21:47 Kingrap#5
you have try whit #include <stdio.h>?

i created for you a function.. i don't have try but i think that he worked..

Code:
#include <stdio.h>

int main()
{
if(remove("myfile..") != 0)
{
perror("Error deleting file");
else
{
puts("File successfully deleted");
}
return 0;
}
}
09/18/2012 00:24 urgabel#6
Errors can be:
1- Invalid filename (maybe wrong path from current).
2- The file is in use (try first closing it).
3- You have no permission.

To ensure, I first would check if filename is ok and the file is found:
Code:
if (FILE * file = fopen("GameGuard\npgg.erl", "r"))
    {
        fclose(file);
        remove(file);
    }