I’m trying to figure out how could I parse this string using “sstream” and C++
The format of it is: “string,int,int”.
I need to be able to assign the first part of the string which contains an IP address to a std::string.
Here is an example of this string:
std::string("127.0.0.1,12,324");
I would then need to obtain
string someString = "127.0.0.1";
int aNumber = 12;
int bNumber = 324;
I will mention again that I can’t use boost library, just sstream 🙂
Thanks
Here’s a useful tokenization function. It doesn’t use streams, but can easily perform the task you require by splitting the string on commas. Then you can do whatever you want with the resulting vector of tokens.