我正在开发一款游戏的原型,并且某些游戏规则将在 ini 文件中定义,以便游戏设计师可以调整游戏参数而无需我的帮助,除了重新编译。这就是我目前正在做的事情:
std::ifstream stream;
stream.open("rules.ini");
if (!stream.is_open())
{
throw new std::exception("Rule file could not be opened");
}
// read file contents here
stream.close();
但是,我的流从未成功打开。在调试期间深入研究 STL 源代码会发现 _getstream()(如 stream.c 中定义的)不断返回 NULL,但我就是不知道为什么会这样。帮助,有人吗?
编辑:Rules.ini 与 .exe 文件位于同一目录中。