问题
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));
}
}
}
but it breaks on the getline
->
Unhandled exception at 0x7730B4D9 (ntdll.dll) in GameCore.exe: 0xC0000005: Access violation writing location 0x00000014.
where it's check
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) );
in the _file.c
file , what's wrong here?
回答1:
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.
来源:https://stackoverflow.com/questions/13272562/fstream-getline-unhandled-exception