#include <iostream> #include <string> using namespace std; using std::string; string restWord(string str); int main() { string str; cout << "Enter the string: " << endl; getline(cin, str); cout << restWord(str) << endl; return 0; } string restWord(string str) { int cnt=0; string result =""; for (int i = 0; !isspace(str[i]) && str.size(); i++) { ++cnt ; } for (int j = cnt + 1; j < str.size(); j++) { result += str[j]; } return result; }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter