0

I am trying to use the std::rename() function to move a .docx file, however, the name of the file may vary. How can I use a std::string within std::rename() so that it does not have to be a hardcoded filepath, like this std::rename(filepath, destination);?

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770

1 Answers1

1

I don't know how you want to populate the strings in question, but here you go:

std::string fromName {"whatever you're going to do"};
std::string toName {"whatever you're going to do"};

std::rename(fromName.c_str(), toName.c_str());
Joseph Larson
  • 8,530
  • 1
  • 19
  • 36