Let me describe this code the way I see it:
for (unsigned i=0; i< octets.size(); i++)
cout << octets[i] << endl;
. Define an empty vector called
. This is like an array which can dynamically resize as and when required. It will hold values of type int.
. Define a stringstream called
. Load into it the existing string
. Define an empty string called
That was just the preparation. Now things get more interesting.
read a line of text from the stream
into the string
. The end of each line is delimited by the
character or the end of the stream.
loop will repeat until all the lines have been read from the stream.
convert the std::string into a null-terminated c-string
convert the contents of the c-string into an integer.
add the value to the vector.
Lines 8 and 9
simply output each entry in the vector.