>文字列型の"30,2"といった物から整数型の30と2を得るにはどのようにすればいいのでしょうか?
について、sscanfと言われ調べて
-------------------------
string str = "30,2";
int x, y;
const char* cs;
cs = str.c_str();
sscanf(cs, "%d,%d", &x, &y);
-------------------------
でできたのですが、istringstream使おうよと言われまた調べて
-------------------------
string str = "30,2";
int x, y;
char c;
istringstream ss(str);
ss >> x >> c >> y;
-------------------------
を作りました。
どちらでも正しく動作するのですが、この場合どちらが適切なんでしょうか?