I need to make a program that gives you the chance to write what you want and then it saves it in .txt.
But all I got so far is this:
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."<<endl;
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
This program makes a .txt file with the sentence written on myfile << "This is a text example, this text will be saved in .txt format."<<endl;
but what I'm trying to do is that the program asks you to write something and that "something" will be saved in a .txt format.
Any ideas?
Just look at it and try to fit it, Alex cpp. Just by looking at that snippet, you can tell myfile has to be an open file, so the snippet must fit somewhere between ofstream myfile ("NotepadExample.txt"); and myfile.close();.