Ok, i did what you said but no luck. Oh, and the bottom portion is something I'm supposed to have as well, so you can ignore it i guess. And you asked about ios::in, well like they say, if it aint broke, dont fix it. it works fine and i used a format similar to this for my last prog and it worked
anyways, my continuing problem:
I'm supposed to create file3.txt with the original contents of file1.txt in addition to the sentence(s) entered by the user.
Code:
string file= "HW7_1.txt";
string line;
ifstream HW7_1txt;
ofstream O_hw7;
string sentence;
char choice;
O_hw7.open("HW7_3.txt", ios::in| ios ::app); //Opens .txt file in input mode and append mode
HW7_1txt.open (file.c_str());
while (getline(HW7_1txt, line));
O_hw7 << line << endl;
HW7_1txt.clear ();
HW7_1txt.close ();
do
{
cout << "Enter a sentence" << endl;
getline (cin, sentence);
std :: cout << "The sentence to be added is: " << sentence << endl;
O_hw7 << sentence<< endl;
cout << "would you like to enter another sentence?" << endl;
cin >> choice;
cin.ignore();
}
while (choice == 'y' || choice == 'Y');
O_hw7.close();