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