I have made this very simpel program and all it needs to do is deleting a file

#include <string>
#include <iostream>
#include <fstream>
int main()
{

string x = "C:\Users\dino\Documents\profiles\fil.txt";
if(remove(x.c_str()) != 0)
    {
        perror("Error deleting ");
    }
return 0;

}

But the perror gives me Invalid argument

Can't i choose the directory of the file I want to delete? if not, is there another way i can?

有帮助吗?

解决方案

You need to escape your string. . .

string x = "C:\\Users\\dino\\Documents\\profiles\\fil.txt";
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top