How to parse complex string with C++?

前端 未结 4 2097
小蘑菇
小蘑菇 2021-02-02 01:02

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 ass

4条回答
  •  野的像风
    2021-02-02 01:32

    The C++ String Toolkit Library (Strtk) has the following solution to your problem:

    int main()
    {
       std::string data("127.0.0.1,12,324");
       string someString;
       int aNumber;
       int bNumber;
       strtk::parse(data,",",someString,aNumber,bNumber);
       return 0;
    }
    

    More examples can be found Here

提交回复
热议问题