summaryrefslogtreecommitdiff
path: root/usr.bin/learn/lib/C/L19.1a
blob: 21e46af064b9993d542d59d560ab068128e5e5ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#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