this program allows the user to name the file and then write text to a .txt file. the only problem is that the program limits how many characters the user can enter. how can i fix this?
Code:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
ofstream myfile;
char text[300];
char text2[20];
cout << "name your file (example.txt)" << endl;
cin.getline(text2,20);
cout << "enter your text" << endl;
cin.getline(text,300);
myfile.open (text2);
myfile << text;
myfile.close();
system ("pause");
return 0;
}
Bookmarks