C++ file streams code example
Example 1: c++ stream string into fiel
#include <fstream>
#include <string>
#include <iostream>
int main()
{
std::string input;
std::cin >> input;
std::ofstream out("output.txt");
out << input;
out.close();
return 0;
}
Example 2: write to file in C++
ofstream myfile;
myfile.open("file.txt");
myfile << "write this to file"