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