I have managed to tokenize my input lines. if i specifically want the 1st & last word & no. of words typed to be printed , how do i code it? I've already tried find_first_of(), but to no good progress. can someone help?
Code:
2 #include <sstream>
3 #include <string>
4 #include <iostream>
5 using namespace std;
6
7 int main ()
8 {
9 string s;
10 char str[100];
11 while (getline(cin,s))
12 {istringstream is(s);
13 while(is >> str)
14 {
15
16 {
17 cout << str << endl;
18 }
19 }
20 }
21 return 0;
22 }