我遇到了从CCString中提取b2vec2坐标的问题,这些坐标来自cocos2dx和box2d。
我尝试过使用strtk,但我无法让它工作
任何帮助都会很棒。
由于
字符串的布局是“x,y x,y x,y” 我想将x和y放入b2vec2
的数组中答案 0 :(得分: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;
}