Hi i am new to programming and trying to write a simple program which is able to read the txt file line by line and append e3 at the end of each line. Can anyone help me in this pgm?
Oh, sorry. I misunderstood - you want the appended strings to be put back into a text file.
You can add this before the return. Beware, giving it the same name as your input file will overwrite it. If you want a separate file, give it a different name.
1 2 3 4 5 6 7 8 9 10 11 12
ofstream out_file ("data.txt");
if (out_file.is_open())
{
for (int i=0; i < str_list.size(); i++)
{
out_file << str_list[i] << "\n";
}
out_file.close()
}
else
cout << "Couldn't open output file\n";