I am trying to exctract "MainLine" from 1 string and two int:s like below but I think I am on wrong track.
If the line was in a .txt file I could do something like this I know but I donĀ“t know if it is different if the Line already is in a std::string ?

char Comma;
std::string LineDummy;
int one = 0;
int two = 0;
MainLine = "Hello,1,2";

while( MainLine, LineDummy, ',')
{
     MainLine >> one;
     MainLine >> Comma;
     MainLine >> two;
}

If its already in std::string then use stringstream

#include <sstream>
...
...
char Comma;
std::string LineDummy;
std::string text;
int one = 0;
int two = 0;
std::string MainLine = "Hello,1,2";
stringstream str(MainLine);
getline(str,text,',');
str >> one >> Comma >> two;
cout << text << "  " << one << "  " << two << "\n";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.