ifstream theFile1("file1.txt"); ifstream theFile2("file2.txt"); string str1, str2, string1, string2; if(!theFile1) { cout << "Error opening file." << endl; return -1; } while (!theFile1.eof()) { getline(theFile1, str1); string1 += str1; string1 += "\n"; }