How can i remove a file from the directory in c++ ?
I know this function int remove ( const char * filename ) deletes the file whose file name is specified in the argument. But it accepts only char* . Is there any other function in c++ that accepts string as it’s argument ?
If you have a
std::string, you can get aconst char*from it by calling itsc_str()member function.The
removefunction from<cstdio>is part of the C Standard Library. C has no concept of classes orstd::string, hence why the function takes aconst char*and not astd::string.