📄 stshtst3.cpp
字号:
//: C06:Stshtst3.cpp
// From Thinking in C++, 2nd Edition
// at http://www.BruceEckel.com
// (c) Bruce Eckel 1999
// Copyright notice in Copyright.txt
//{L} Stash3
// Constructors & destructors
#include <cstdio>
#include "../require.h"
#include "Stash3.h"
using namespace std;
#define BUFSIZE 80
int main() {
Stash intStash(sizeof(int));
for(int j = 0; j < 100; j++)
intStash.add(&j);
FILE* file = fopen("Stshtst3.cpp", "r");
require(file);
// Holds 80-character strings:
Stash stringStash(sizeof(char) * BUFSIZE);
char buf[BUFSIZE];
while(fgets(buf, BUFSIZE, file))
stringStash.add(buf);
fclose(file);
for(int k = 0; k < intStash.count(); k++)
printf("intStash.fetch(%d) = %d\n", k,
*(int*)intStash.fetch(k));
for(int i = 0; i < stringStash.count(); i++)
printf("stringStash.fetch(%d) = %s",
i, (char*)stringStash.fetch(i++));
putchar('\n');
} ///:~
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -