Answers for "c++ write to file in directory"

C++
0

c++ write to file in directory

ofstream myFile("/Your/File/Path/YourFilename.txt");//writing to this file
if (myFile.is_open())
{
   myFile << "This is a line." << "\n";
   myFile << "This is another line." << "\n";
   myFile.close();
}
else
   std::cout << "Unable to open file";
Posted by: Guest on April-13-2021

Browse Popular Code Answers by Language