字符串处理
istringstream 根据空格分隔字符串 string转int i = stoi(s) int转string s = to_string(i) 示例如下
#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main(){
string s = "a 5 *";
istringstream iss(s);
string tmp;
while(iss >> tmp){
cout << tmp << endl;
}
int i;
i = stoi("1");
cout << i << endl;
cout << to_string(i) << endl;
return 0;
}
/* 输出
a
5
*
1
1
*/
转载于:https://www.cnblogs.com/qbits/p/10980466.html
相关资源:数据结构—成绩单生成器