what kind of input do you want to insert to your .txt file?
edit:
i'm a beginner too.. but i have given this thing before..
so let me help you.. :)
first, you have to know what kind of data you want to insert into the text file..
for instance, we want to create a data file consist of people's name based on user input..
then we can use a character array..
so just define it
char userInput [size];
the
size is depends on you.. let's say the size is 20..
let user input the data..
1 2 3
|
cout << "Please enter the data that you want to insert into the text file: ";
cin >> userInput;
|
because i don't know how many data you wish to insert, i guess it's better to use do-while..
something like this..
1 2 3 4 5 6 7 8
|
char option;
do
{
//the code above
cout << "Wish to enter another data (Y/N)?" ;
cin >> option;
} (option != n);
|
then.. you can write those data into the text file, just like a normal cout..
but the difference is that you use the name that you declare using fstream..
something like this :
myFile << userInput << endl;
i hope this can help.. :)