So I have to use peek and get in this code to see if the next character is a whitespace. While there is a white space, it runs true. As long as it is a white space it will keep grabbing the white space until there is no longer a white space. Once there is no white space, it ends the loop and returns the collected characters into a vector of strings. However I can't seem to make the correct use of peek and get.
istream::peek reads the next character in the input sequence, so you'd have to work at char level first before converting to std::string if your assignment so demands.
Below is a program to separate the input std::string into space and non-space std::vector<char> using peek() and get().
You can then convert the std::vectors (or at least the non-space std::vector<char>) to std::string but be aware that you'd have lost the words from the input string during the transition.
So to reconstitute the words from the std::vector<char> you'd have to keep a running tally of where in the input string the whitespaces occur and corresponding to those numbers you'd add up the chars to give back the words.
There are, of course, other (simpler) ways to parse a std::string by whitespace to split it into consituent words not involving peek(), get() etc: