8.10
#include <sstream> #include <fstream> #include <iostream> #include <string> #include <vector> using namespace std; void main() { vector <string> ch; string word, line; ifstream input("test.txt"); if (!input) cerr << "cannot open file!"; while (getline(input, line)) ch.push_back(line); input.close(); for (auto s : ch) { istringstream record(s); while (record >> word) cout << word << ‘\n‘; } system("pause"); }
时间: 2024-11-08 19:02:36