問題(Question):
這問題我一直找不到適合的解法,想問問大家意見
C++11中,printf的替代品已經有[fmt](https://github.com/fmtlib/fmt)可以用了
不過scanf一直沒辦法
去StackOverflow找到推薦的解法大概長這樣
std::stringstream s("123 456 789");
int a, b, c;
s >> a >> b >> c;
這方法跟strtok差不多,不過遇到更困難的pattern
char str[] = "The value is 10, 3.3.";
int v;
double v1;
sscanf(str, "The value is %d, %lf", &v, &v1);
相對於stringstream,scanf的方式平易近人多了(雖然日後出包的機會也不少)
有更好得作法嘛?