C++读取txt文件

------------恢复内容开始------------

#include <iostream>
#include <string>
using namespace std;
int main()
{
    string line;
    while (getline(cin, line))
    {
        cout << line;
    }
    return 0;
}

运行结果:

 

 

 需要将txt文档和编写的程序放在同一个文件夹中

 

 

 

 

------------恢复内容结束------------

posted @ 2020-02-05 20:33  菜鸟冲冲冲  阅读(978)  评论(0)    收藏  举报