gpt4 book ai didi

c++ - fstream getline() 未处理的异常

转载 作者:行者123 更新时间:2023-11-30 04:23:37 36 4
gpt4 key购买 nike

我正在尝试读取一个文件,所以我正在做:-

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++ > 代码生成 > 运行时库。确保它对于所有依赖项都是一致的,并且根据当前构建将其设置为调试/发布变体。

关于c++ - fstream getline() 未处理的异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13272562/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com