⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c04p201.txt

📁 Data Abstraction & Problem Solving with C++源码
💻 TXT
字号:
// Creates a linked list from the data in a text // file. The pointer variables head and tail are// initially NULL. fileName is a string that names// an existing external text file.ifstream inFile(fileName);int      nextItem;if (inFile >> nextItem)               // is file empty?{  // file not empty:   head = new Node;   // add the first integer to the list   head->item = nextItem;   head->next = NULL;   tail = head;   // add remaining integers to linked list   while (inFile >> nextItem)   {  tail->next = new Node;      tail = tail->next;      tail->item = nextItem;      tail->next = NULL;   }  // end while}  w// end ifinFile.close();// Assertion: head points to the first node of the// created linked list; tail points to the last// node. If the file is empty, head and tail are// NULL (list is empty).

⌨️ 快捷键说明

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