c 2b 2b split string by comma into array

Solutions on MaxInterview for c 2b 2b split string by comma into array by the best coders in the world

showing results for - "c 2b 2b split string by comma into array"
Dagmar
19 Oct 2020
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}
queries leading to this page
c 2b 2b input split by commac 2b 2b split string with commasplit words to array in c 2b 2bc 2b 2b split with commasplit string by comma in c 2b 2bsplit string c 2b 2b by commac 2b 2b split a string by commahow to make an array from a string splitting comma separated values c 2b 2bsplit by comma string cppsplit a string on comma c 2b 2b stlstring split by comma c 2b 2bread a string from file split by comma into array c 2b 2bseprate string on comma c 2b 2bcpp string split by commasplit string by comma c 2b 2bsplit line by comma c 2b 2bhow to split text by comma in c 2b 2bc 2b 2b split by comma into arrayhow to make a array from a string splitting comma separated values c 2b 2bc 2b 2b split line by commaspit string by comma in c 2b 2bsplit the string with comma in c 2b 2bcpp split by commaseparate string with comma c 2b 2bc 2b 2b cpp get comma separated string to arrayc 2b 2b split by commahow to split string at comma in c 2b 2bseparate by comma c 2b 2bhow to split c 2b 2b string by commac 2b 2b get comma separated string to arraysplit a string separated by comma in c 2b 2bc 2b 2b split string by comma into arrayc 2b 2b stringstream split by commac 2b 2b split string by commacpp split string by commasplit array on comma c 2b 2bc 2b 2b separate 1 string by commaspit string by comma in c 2bseparate string by comma c 2b 2bsplit a string on comma c 2b 2bhow to split a string in c 2b 2b by commac 2b 2b string split by commac 2b 2b separate string by commaseparate string into commas in cppsplit by comma cppc 2b 2b splitting string by commac 2b 2b cstring split by commasplit a string contain comma and store in array cpphow to split a comma delimited string in c 2b 2bcpp split line with commac 2b 2b split string by comma into array