1#include <vector>
2#include <string>
3#include <sstream>
4#include <iostream>
5using namespace std;
6
7int main()
8{
9 string s="i,love,my,country,very,much"; //declare a string
10 string answer[6]; // string array to store the result
11 stringstream string_stream(s); // creating string stream object
12 int i=0; // declaring i and assign to 0
13
14 while(string_stream.good()) // loop will continue if string stream is error free
15 {
16 string a;
17 getline( string_stream, a, ',' ); //calling getline fuction
18 answer[i]=a;
19 i++;
20 }
21
22 for(i=0;i<6;i++)
23 {
24 cout<<answer[i]<<endl; // printing a result
25 }
26 return 0;
27}