2.9BSD/usr/lib/learn/C/L19.1a
#print
Write a subroutine which counts the number of times it has
been called and returns that count each time. Name it
"count()". Write it on a file named "count.c". Compile
and test it; type "ready" when happy.
#once #create Ref
23080
#once #create tzaqc.c
main() {
int i;
for (i = 0; i < 23079; i++)
count();
printf("%d\n", count());
}
#user
cc tzaqc.c count.o
a.out >value
#cmp value Ref
#succeed
/* one way */
count()
{
static int n = 0;
return(++n);
}
#log
#next
30.1a 10
20.1a 5