문제

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