#include <iostream>
using namespace std;
#include <fstream>//1.包含读文件
//文本文件 读文件
void test01()
{
//2.创建流对象
ifstream ifs;
//3.打开文件,并判断是否打开成功
ifs.open("C:\\Users\\Lenovo\\Desktop\\test.txt", ios::in); //"C:\\Users\\Lenovo\\Desktop\\test.txt",把“\”改成“\\”
if (!ifs.is_open())
{
cout << "文件打开失败" << endl;
return;
}
char c;
while ((c = ifs.get()) != EOF)//EOF end of file
{
cout << c;
}
//5.关闭文件
ifs.close();
}
int main()
{
test01();
return 0;
}