我正在编写一个 C++ 程序来读取一个 exe 文件。我写了它并在文本文件而不是 exe 文件上测试它。这是真的。
当我使用 exe 文件对其进行测试时,我了解到我的 exe 文件中有 0x00 值(不是在其末尾)。所以我的 while 循环在文件结束前停止,因为我使用了:
class A{
private:
ifstream myFile;
void Read(char *filename)
};
void A::Read(char *str)
{
myFile.open(str,ios::binary);
while (!myFile.eof())
{
InputFile.get(ch);
myString.push_back(ch);
}
}
我该怎么办?如果我应该使用文件的大小,我怎样才能得到它?
最佳答案
您必须使用 std::ios::binary
模式标志打开文件流。
关于c++ - C++中的Exe文件的结尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9339852/