I'm passing an ofstream object to a function within my program. In that function, I'd like to extract the path and filename of the ofstream object, modify the filename only, create a new ofstream object using the old path and new filename and write something to it.
How do I get the path and filename of a passed ofstream object?
How do I get the path and filename of a passed ofstream object?
Code:
std::ostream& Func::writeOut(std::ostream& out) { std::string sPath = getPath(out) // how do I implement this? std::string sFile = sPath + "//NewFile"; std::ofstream oFile(sFile, std::ios::out); sFile << "Write something" << std::endl; return(out); }
Comment