#include <iostream>
#include <sstream>
#include <string>

std::string GetNthWord(std::string s, std::size_t n)
{
    std::istringstream iss (s);
    while(n-- > 0 && (iss >> s));
    return s;
}

int main()
{
    std::cout << GetNthWord("I hope that you can figure out how this works.", 4) << std::endl;
}