The STL function you're thinking of is istream::getline. You use the second argument to change the delimiter from the default newline to whatever separator you want, in this case a space.

To allow for cases where there are multiple spaces between words, you'll also need a function to strip leading/trailing space off the resulting strings. The std::string class provides everything you need to implement this.