下面是演示代码
#include
#include
int main()
{
ifstream infile;
infile.open("liuhfc.txt"); //打开文件,注意文件路径
if(!infile.is_open()) return 0;
string s;//要保持读取文件内容的string
while(getline(infile,s))
{
cout<}
infile.close(); //关闭文件输入流
return 0;
}