8vi.cpp
来自「《C/C++程序设计导论(第二版)》一书的程序源文件」· C++ 代码 · 共 22 行
CPP
22 行
// MakeList () Make a list of current meds in file "temp.txt"
// ASSUMPTIONS: patfile is opened to the file "patients.txt". outfile is
// opened to the file "temp.txt". Lowest patID is 1111, highest drug
// number is 99. Assumes patient is in file. Sentinel is END.
// IN: patID is the patient ID number.
// IN/OUT: patfile is opened to "patients.txt", outfile to "temp.txt"
void MakeList (int patID, ifstream& patfile, ofstream& outfile)
{ int drug, id;
patfile >> id;
while (patfile && id != patID) // find the correct patient
patfile >> id;
if (patfile)
{ patfile >> drug; // make list of current meds
while (drug > 0) // in file using `outfile'
{ outfile << " " << drug;
patfile >> drug;
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?