|Here we have two strings populated by input (cin) as, say, fisrtplace and secondplace.|
In line 9 and 10 we assign a file-stream-for-reading/writing named is and os respectively.
The user enters the input and output filenames respectively. is and os are opened for read / write using the user-supplied filenames.
|In line 12 we assign an istream-iterator to is named ii. And another to (?) named eos in line 13.|
is set to the start of the input file
. The iterator
is default-constructed to end-of-stream.
|In 14 we set an ostream-iterator to os named oo. What do we use a "\n" there?|
"\n" is the delimiter, to separate each item written to the output.
|Then we have a vector named b initialized with two iterators ii and eos.|
The vector is filled with whatever is contained in the range specified by the two iterators, that is from start of the input file to its end.
|We sort (sort what?) in line 17.|
is sorted. That is the the vector declared on the previous line.
|And in 18 we copy the vector from its beginning to its end to oo.|
That is, all the strings in the vector b are written to the output file, separated by a newline "\n".
|But in essence, when I print the vector nothing is sorted and nothing is entered either!|
Was my thoughts above correct?
And why does the vector not have any input please?
Your thoughts were mostly correct at one level. I'm not sure you expressed the meaning of what the code was intended to achieve. i.e. get the filenames from the user, read all the strings from one file into a vector, sort it, write the words out to another file, and display the words on the console.
Are you sure you supplied a valid name for the input file?