c++逐行读取txt文件 getline()
#include
#include
#include
using namespace std;
int main()
{
ifstream fin;
fin.open("word.txt");
string str;
while (!fin.eof())
{
getline(fin, str);
cout << str<< endl;
}
fin.close();
}
#include
#include
using namespace std;
int main()
{
ifstream fin;
fin.open("word.txt");
string str;
while (!fin.eof())
{
getline(fin, str);
cout << str<< endl;
}
fin.close();
}
声明:该文观点仅代表作者本人,入门客AI创业平台信息发布平台仅提供信息存储空间服务,如有疑问请联系rumenke@qq.com。
- 上一篇: ofstream的使用方法--超级精细。C++文件写入、读出函数(转)
- 下一篇:没有了
