apa*_*ual 1 c++ parsing coordinates
我想知道哪种方法是解析string
C++ 中相同坐标的最佳方法。
例子:
1,5
42.324234,-2.656264
Run Code Online (Sandbox Code Playgroud)
结果应该是两个double
变量...
如果字符串的格式总是像x,y
,那么这应该就足够了。
#include <string>
#include <sstream>
double x, y;
char sep;
string str = "42.324234,-2.656264";
istringstream iss(str);
iss >> x;
iss >> sep;
iss >> y;
Run Code Online (Sandbox Code Playgroud)