-1
失败我目前使用的Visual Studio 2015年阅读文件在C++中
#include "stdafx.h"
#include "fstream"
#include "iostream"
using namespace std;
int main() {
ifstream infile;
infile.open("hello.txt");
if (infile.fail()) {
cerr << "error to open";
exit(1);
}
int x, y;
infile >> x >> y;
cout << x << y << endl;
return 0;
}
- 我包括资源文件夹中的文件hello.txt的。
它仍然没有从文件中读取它。
我不确定它的视觉工作室或其他东西的设置问题。
难道你是单独运行程序还是使用附加的调试器? (在Visual Studio中运行) –
你是什么意思“仍然没有从文件中读取它”? – Carcigenicate
添加一些临时代码,用于写入文件以打开文件。查看文件的创建位置,然后将输入文件放在同一目录中。 –