配置路径
VS main 函数的argc、argv参数,配置路径:
Project -> Properties -> Configuration Properties -> Debugging
在Command Arguments里填上即可。
配置文件读取
ifstream inFile(argv[1]);
if (!inFile)
{
cerr << "Cannot find input file " << argv[1] << "!!\n" << endl;
cin.get();
exit(1);
}
或者
ifstream inFile;
inFile.open("C:\\boot.ini");
之后逐行读取文件(注意,inFile忽略空行):
string stringBuff;
int integerBuff;
double doubleBuff;
int Num_Cat;
double CatWeight;
/************ read a string ****************/
inFile >> stringBuff;
if (stringBuff == "FULL_BUFFER_MODEL")
{
TrafficModel = FULL_BUFFER;
}
/************ read a integer ****************/
inFile >> integerBuff;
Num_Cat = integerBuff;
/************ read a string ****************/
inFile >> doubleBuff;
CatWeight = doubleBuff;
关闭文件;
inFile.close();