我有一个名为settings.txt
的文本文件。它里面我有它说:从文本文件加载值C++
Name = Dave
然后我打开该文件,并循环在我的脚本的线条和文字:
std::ifstream file("Settings.txt");
std::string line;
while(std::getline(file, line))
{
for(int i = 0; i < line.length(); i++){
char ch = line[i];
if(!isspace(ch)){ //skip white space
}
}
}
什么,我试图找出是将每个值分配给某种变量,这些变量将被视为我游戏的“全局设置”。
所以,最终的结果会是这样的:
Username = Dave;
但以这样的方式,我可以在日后添加额外的设置。我不知道你会怎么做=
使用容器。 –
你知道我可以在网上看到的任何示例脚本吗? – Sir
std :: map我想是你想存储它。 –