Sometime it is needed to parse a input line according to requirement. For example, I may need to separate the words by whitespaces, comma, hyphen etc.
One example is given below to parse the input line by comma:
string input = "abc d,ef,ghi"; istringstream ss(input); string token; while(getline(ss, token, ',')) { cout << token << '\n'; }
Output will be:
abc d ef ghi
reference from stackoverflow