#include <iostream>
#include <string>
#include <sstream>
using namespace std;
int main()
{
string lit = "378+123;";
istringstream instr(lit);
int word;
while(instr >> word)
cout << word << endl;
return 0;
}
结果当然是 378 123啦
#include <string>
#include <sstream>
using namespace std;
int main()
{
string lit = "378+123;";
istringstream instr(lit);
int word;
while(instr >> word)
cout << word << endl;
return 0;
}
结果当然是 378 123啦
本文介绍了一个简单的C++程序,该程序使用istringstream从一个包含整数的字符串中读取并打印这些整数。通过这个例子,读者可以了解到如何利用istringstream来解析特定格式的数据。
3900

被折叠的 条评论
为什么被折叠?



