I have a c++ program where it take data from a file. In file data is as follows:
this is line 1
this is line 2
this is line 3
Here's how I read it.
ifstream file;
std::string list[max], temp;
file.open("file");
int i=0;
while ( getline (file, temp )) //while the end of file is NOT reached
{
list[i] = temp;
i++;
}
file.close();
Now what I do is run a loop as follows
for(i=0; i<no_of_lines; i++){
temp = list[i];
}
What i want is to reverse the line. For example in line 1 data is 'this is line 1' and update data in temp as '1 line is this'
How can I achieve that?