Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <fstream>
- using namespace std;
- int main()
- {
- int choice;
- line11:
- cout<< "Do you want to create a new file?\n";
- cout<< "1) Yes\n";
- cout<< "2) No\n";
- cin>> choice; cin.get();
- if (choice == 1)
- {
- string fileName;
- cout<<"Enter filename";
- getline(cin, fileName);
- fstream myFile(fileName, ios::in | ios::out | ios::app);
- string textInput;
- if (myFile.is_open())
- {
- cout<< "Enter text line by line, type end when finished\n";
- while (textInput != "end")
- {
- getline(cin, textInput);
- myFile<< textInput << endl;
- }
- }
- else
- {
- cout<<"ERROR:FILE NOT FOUND"<<endl;
- cin.get();
- }
- }
- /*
- else if (choice == 2)
- {
- goto line33;
- }
- else
- {
- cout<< "Invalid choice\n";
- goto line11;
- }
- line33:;*/
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement