8vii.cpp

来自「C/C++程序设计导论(第二版)》程序源文件」· C++ 代码 · 共 18 行

CPP
18
字号

// FindDrug()  Locate the correct drug record in "drugs.txt"
// ASSUMPTIONS: file "drugs.txt" is opened to `drugfile'.
//	List sentinal is END. newdrug must be found in file.
// IN: newdrug is the drug to be found.
// IN/OUT:  drugfile is opened to "drugs.txt"
void FindDrug (ifstream& drugfile, int newdrug)
{	int thisdrug;
	drugfile >> thisdrug;				// first drug for each record
	while (drugfile && thisdrug != newdrug)
		{ 	drugfile >> thisdrug;		// if wrong drug, skip over list
			while (thisdrug > 0)
				drugfile >> thisdrug;
			drugfile >> thisdrug;		// and get next drug record
		}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?