I'm trying to make a program where you write what you want and then it saves it in a ".txt" file, can someone please write the code or at least help me please?
(I'm still a beginner with c++)
I can't figure it out, this program here should save in .txt what it's written in the "myfile <<..."
but how do i do it if I want to enter wat to save?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
#include <fstream>
usingnamespace std;
int main () {
ofstream myfile ("NotepadExample.txt");
if (myfile.is_open())
{
myfile << "This is a text example, this text will be saved in .txt format."<<testo<<endl;
myfile.close();
}
else cout << "Unable to open file";
return 0;
}