C++ 简单阅读中的垃圾 int测试=0; 河流充填; infle.open(“hat.txt”); 填充>>试验; 不能
在一个数字后面有一行结尾吗?众所周知,这会导致某些工具集出现问题。调试文件夹(您所说的C++ 简单阅读中的垃圾 int测试=0; 河流充填; infle.open(“hat.txt”); 填充>>试验; 不能,c++,C++,在一个数字后面有一行结尾吗?众所周知,这会导致某些工具集出现问题。调试文件夹(您所说的hat.txt所在的位置)也是您的工作目录吗? hat.txt是否以任何方式锁定(例如在应用程序中打开)?检查失败后,您的代码看起来很好 为什么失败了?该文件可能不存在或具有错误的权限 我运行了这个代码 int test; ifstream inFile; inFile.open("hat.txt"); if ( inFile.fail() ) { cout << "It Failed" &
hat.txt
所在的位置)也是您的工作目录吗?hat.txt
是否以任何方式锁定(例如在应用程序中打开)?检查失败后,您的代码看起来很好
为什么失败了?该文件可能不存在或具有错误的权限
我运行了这个代码
int test;
ifstream inFile;
inFile.open("hat.txt");
if ( inFile.fail() )
{
cout << "It Failed" << endl;
}
inFile >> test;
cout << test;
#包括
#包括
使用名称空间std;
int main()
{
智力测验;
std::ifstream-infle;
infle.open(“hat.txt”);
if(infle.fail())
{
库特试验;
cout看起来默认情况下,您可以使用read或getline将文本读入字符串。您可以使用ios::binary标志将ifstream更改为二进制。然后您可以设置缓冲区并直接读入该缓冲区。然后您需要转换以作为文本输出。hat.txt是否位于正确位置?
int test;
ifstream inFile;
inFile.open("hat.txt");
if ( inFile.fail() )
{
cout << "It Failed" << endl;
}
inFile >> test;
cout << test;
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
int test;
std::ifstream inFile;
inFile.open("hat.txt");
if ( inFile.fail() )
{
cout << "It Failed" << endl;
}
inFile >> test;
cout << test;
return 0;
}