Apr 12, 2014 at 6:34pm UTC
I'm using the code found on the site here:
1 2 3 4 5 6 7 8 9 10 11
//* remove example: remove myfile.txt */
#include <stdio.h>
int main ()
{
if ( remove( "myfile.txt" ) != 0 )
perror( "Error deleting file" );
else
puts( "File successfully deleted" );
return 0;
}
I replaced the myfile.txt with the directory of the file I want deleted.
"C:\SOUNDS\savegame.dat"
It returns: Error deleting file. No such file or directory exists.
I've triple checked the directory. Its correct. I must be using this incorrectly. How?
Last edited on Apr 12, 2014 at 6:35pm UTC
Apr 12, 2014 at 7:15pm UTC
Are you using double slashes?
"C:\\SOUNDS\\savegame.dat"
Apr 12, 2014 at 8:04pm UTC
That did it, I didn't see any mention of that in the article so I wasn't aware that was necesary. Is that only for remove?
Thanks for the help.
Apr 12, 2014 at 8:30pm UTC
That's why you should never use backslashes for paths. All operating systems support forward slashes, so always use forward slashes for paths. Only some operating systems support backslashes, and they have to be escaped, so don't use them.
Apr 12, 2014 at 8:33pm UTC
I see now, that makes sense, appreciate the input.