明明文件的路径是正确的,就是打不开文件,各位有发现什么问题吗?
#include <iostream>
#include<fstream>
#include<string>
using namespace std;
void test01()
{
ifstream ifs;
ifs.open("test.txt", ios::in);
if (!ifs.is_open()) { cout << "文件打开失败" << endl; return; }
string str;
while (getline(ifs, str))
{
cout << str << endl;
}
ifs.close();
}
int main() {
test01();
system("pause");
return 0;
}