#include <sstream>
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
void TestIstringStream(void)
{
string word, line;
getline(cin, line);
istringstream isstream(line);
while (isstream >> word)
{
cout<< word.c_str() << endl;
}
}
输入:
ag dfd kk
输出:
ag
dfd
kk
本文介绍了一个简单的C++程序示例,演示如何使用istringstream类从单行输入中读取并逐个打印出单词。该程序首先获取用户输入的一行文本,然后使用istringstream来逐词解析这些文本。
1306

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



