lundi 2 septembre 2019

User specified file removal using remove function in C++

I'm attempting to add the ability for players to be able to delete their save.txt files from the games folder

 remove("Saves/" + FileName + ".txt");

I tried to use the remove function which has worked well for me before, with the user entered FileName String in the middle but this gives me the error message 'error: cannot convert 'std::__cxx11::basic_string' to 'const char*' for argument '1' to 'int remove(const char*)'|'

So after searching this I tried:

 const char * FileNames = FileName.c_str();

Turning filename into a char but now the compiler says I can't use the operands + or << to add the char

I'm now a little lost

Any help would be greatly appreciated

Aucun commentaire:

Enregistrer un commentaire