File:  [CSRG BSD Unix] / 43BSD / usr.lib / learn / C / L19.1a
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:55 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43
BSD 4.3

#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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.