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
  • 505,946
  • 29
  • 409
  • 696

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
  • 7,591
  • 1
  • 17
  • 31