我无法使用 fstream 读取.dat文件
I can't read a .dat file using fstream
我知道这个主题有很多问题,但我无法解决。这个程序在我的笔记本电脑上运行得很好,但当我试图在学校的Linux实验室中编译和运行它时,这个程序无法打开文件。我曾尝试定义文件的绝对位置,但没有任何效果。文件名是正确的,但当我尝试运行程序时,它显示"失败"。我正在使用gedit并使用bash编译程序。
ifstream fin("rainfall.dat"); // If the file cannot open display failed
if(fin.fail()){
cout << "failed" << endl;
return 1;
}
尝试
#include <errno.h>
if(fin.fail())
perror("open failed ");
这将为最后一个错误
相关文章:
- 在 c++ 中读取和写入.dat文件
- 在 c++ 中错误地读取.dat文件
- (C++) 如何从要存储在结构数组中的二进制文件中读取.dat信息?
- 无法读取一个.dat文件以创建第二个.dat文件
- 读取.DAT文件并创建一个数组C
- 无法读取 Ubuntu "Segmentation fault (core dumped)"中的.dat或.bin文件
- 读取和写入.dat文件
- 使用 std::write 和 std::read C++ 读取包含 std::string 到.dat文件的结构
- 一次读取两个字节的.dat文件
- 正在从.dat文件中读取2个字节
- 正在从dat文件读取到数组中
- 如何在不显示十六进制的情况下读取dat文件中的文本?C++
- 如何使用条带化算法读取住宅.dat文件C++
- 从文件读取(.dat)进行计算,然后输出到新文件中
- C++ 读取文件.dat中保存的对象
- 写入和读取记录以.dat文件C++
- 将.dat文件中的参数读取到C++中
- 我无法使用 fstream 读取.dat文件
- 如何在c++中读取.dat文件
- 循环错误地读取dat文件