while (cin >> word) {} demo

来源:互联网 发布:最强大脑 小度 知乎 编辑:程序博客网 时间:2024/06/06 03:55
#include <iostream>#include <fstream>using namespace std;int main(){    ifstream infile("data.txt");    if (!infile) {        cerr << "fail to open file!" << endl;        return -1;    }    string word;    while (infile >> word) {        cout << word << endl;    }    return 0;}

0 0
原创粉丝点击