c++ writing to file
// basic file operations
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream myfile;
myfile.open ("example.txt");
myfile << "Writing this to a file.\n";
myfile.close();
return 0;
}
c++ writing to file
// basic file operations
#include <iostream>
#include <fstream>
using namespace std;
int main () {
ofstream myfile;
myfile.open ("example.txt");
myfile << "Writing this to a file.\n";
myfile.close();
return 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";
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us