file en c++ code example
Example: file c++
#include <iostream>
#include <string>
#include <fstream> //write and read
//#include <ifstream> //read
//#include <ofstream> //write
int main () {
std::string line;
std::ofstream myfileWrite;
std::ifstream myfileRead;
myfileWrite.open("example.txt");
myfileRead.open("example.txt");
myfileWrite << "Writing this to a file.\n";
while (getline(myfileRead,line)){
std::cout << line << '\n';
}
myfileWrite.close();
myfileRead.close();
return 0;
}