📄 nesttest.cpp
字号:
//: C04:NestTest.cpp
// From Thinking in C++, 2nd Edition
// at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
//{L} Nested
//{T} NestTest.cpp
// Test of nested linked list
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include "../require.h"
#include "Nested.h"
using namespace std;
int main(int argc, char* argv[]) {
Stack textlines;
FILE* file;
char* s;
#define BUFSIZE 100
char buf[BUFSIZE];
requireArgs(argc, 2); // File name is argument
textlines.initialize();
file = fopen(argv[1], "r");
require(file != 0);
// Read file and store lines in the Stack:
while(fgets(buf, BUFSIZE, file)) {
char* string =(char*)malloc(strlen(buf)+1);
require(string != 0);
strcpy(string, buf);
textlines.push(string);
}
// Pop the lines from the Stack and print them:
while((s = (char*)textlines.pop()) != 0) {
printf("%s", s); free(s); }
textlines.cleanup();
} ///:~
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -