ofstream myFile("/Your/File/Path/YourFilename.txt");//writing to this file if (myFile.is_open()) { myFile << "This is a line." << " "; myFile << "This is another line." << " "; myFile.close(); } else std::cout << "Unable to open file";