从String中提取X和Y坐标

use*_*362 10 string extract box2d cocos2d-x

我从CCString中提取b2vec2坐标时遇到问题,这些坐标来自cocos2dx和box2d.

我尝试过使用strtk,但我无法使用它

任何帮助都会很棒.

谢谢

字符串的布局是"x,yx,yx,y"我想将x和y放入b2vec2的数组中

And*_*rew 1

string s = "12,4 4,5 6,3";

istringstream is(s);
while (is.good())
{
    int x, y;
    char comma;
    is >> x >> comma >> y;

    cout << x << ", " << y << endl;
}
Run Code Online (Sandbox Code Playgroud)