本文介绍了fstream getline()未处理的异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试读取文件,所以正在做:-
am trying to read a file so am doing:-
void Load(const char * Name){
fs.open(Name, std::ifstream::in);
char temp[256];
if(fs.is_open()){
while (!fs.eof())
{
fs.getline(temp , 256);
Lines.push_back(new std::string(temp));
}
}
}
但它在getline
->
Unhandled exception at 0x7730B4D9 (ntdll.dll) in GameCore.exe: 0xC0000005: Access violation writing location 0x00000014.
要检查的地方
else
/*
* Not part of _iob[]. Therefore, *pf is a _FILEX and the
* lock field of the struct is an initialized critical
* section.
*/
EnterCriticalSection( &(((_FILEX *)pf)->lock) );
在_file.c
文件中,这怎么了?
推荐答案
遇到此类问题时,您可能需要仔细检查项目配置.例如,在MSVC中,检查项目属性>配置属性> C/C ++>代码生成>运行时库.确保所有依赖项的一致性,并根据当前内部版本将其设置为Debug/Release变量.
When you encounter these sorts of issues you may want to double check your project configuration. For example, in MSVC check your Project Properties > Configuration Properties > C/C++ > Code Generation > Runtime Library. Make sure it consistent for all dependencies and that it is set to a Debug/Release variant depending on the current build.
这篇关于fstream getline()未处理的异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!