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