Parse (split) a string in C++ using string delimiter (standard C++)

后端 未结 20 2106
时光说笑
时光说笑 2020-11-21 23:44

I am parsing a string in C++ using the following:

using namespace std;

string parsed,input=\"text to be parsed\";
stringstream input_stringstream(input);

i         


        
20条回答
  •  伪装坚强ぢ
    2020-11-22 00:11

    #include
    #include
    using namespace std;
    
    int split_count(string str,char delimit){
    return count(str.begin(),str.end(),delimit);
    }
    
    void split(string str,char delimit,string res[]){
    int a=0,i=0;
    while(a

    P.S: Works only if the lengths of the strings after splitting are equal

提交回复
热议问题