[英]fstream constructor causing access violation
I'm having trouble reading from a file. 我无法读取文件。 I've cut my program down and down until all I'm left with is not much more than Hello World - and I'm still getting an error of 'access violation'.
我一直在缩减程序,直到剩下的只剩下Hello World为止,并且仍然出现“访问冲突”错误。
The error is occuring on the line fstream f(..); 错误发生在fstream f(..)行上; - it never gets as far as f.good().
-它永远不会达到f.good()。 The only changes to this project have been to include ozz-animation header files and .lib's (easily found on Google), as well as setting Runtime Library mode to /MT rather than /MD.
对该项目的唯一更改是包括ozz-animation头文件和.lib(可在Google上轻松找到),以及将运行时库模式设置为/ MT而不是/ MD。 Ozz was throwing the same error when attempting to read a file (hence the cutting down until I'm left with what you see).
尝试读取文件时,Ozz引发了相同的错误(因此请进行删节,直到我看到您所看到的为止)。 The file is present, although I don't believe it should matter.
该文件存在,尽管我认为这不重要。 Code is as follows:
代码如下:
#pragma once
#include <Windows.h>
#include <fstream>
using namespace std;
int main()
{
fstream f("C:\\Users\\thoma_000\\Desktop\\Limitless\\Bin\\Asset\\skin_example\\A.txt");
if (f.good())
{
OutputDebugString(L"\n\n\nGOOD.\n\n\n");
}
else
{
OutputDebugString(L"\n\n\nBAD.\n\n\n");
}
return 0;
}
I managed to resolve this by creating the project initially as an empty win32 project rather than a Windows project. 我设法通过最初将项目创建为空的win32项目而不是Windows项目来解决此问题。 I have been through the project settings and I currently can't tell what setting is causing the problem - but at least I have a resolution.
我已经完成了项目设置,但目前无法确定是什么设置导致了问题-但至少我有解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.