📄 example199.cpp
字号:
#include <iostream>#include <fstream>#include <string>using namespace std;struct Node{ int item; Node *next;}; // end structint main(){ Node *head = NULL; head = new Node; head->item = 1; Node *p = head; for (int i=2; i<=5; i++) { p->next = new Node; p = p->next; p->item = i; } p->next = NULL; // Saves a linked list's data in a text file of // integers; head points to the linked list. string fileName = "numbers.txt"; // fileName is a string that names an external text // file to be created ofstream outFile(fileName); // traverse the list to the end, writing each item for (Node *cur = head; cur != NULL; cur = cur->next) outFile << cur->item << endl; outFile.close(); // Assertion: The text file contains the linked // list抯 data in its original order. return 0;} // end main
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -