【问题标题】:Extract X and Y Coordinates from String从字符串中提取 X 和 Y 坐标
【发布时间】:2012-07-13 11:13:44
【问题描述】:

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

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

任何帮助都会很棒。

谢谢

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

【问题讨论】:

标签: string box2d extract cocos2d-x


【解决方案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;
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-04-30
    • 2022-11-13
    • 1970-01-01
    相关资源
    最近更新 更多