File:  [CSRG BSD Unix] / 43BSD / usr.lib / learn / C / L33.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 main program which counts the number of command-line arguments
it has which begin with the letter 'b'.  Print the
result in decimal.  Compile and test it as usual.
Then type "ready".
#user
a.out abc bcd efg rpq b bbvd  >xxx
grep 3 xxx >/dev/null
#succeed
/*  a possible solution */
main(argc, argv)
char *argv[];
{
	int i, k;

	for(i=k=0; i<argc; i++)
		if (argv[i][0] == 'b')
			k++;
	printf("%d\n", k);
}
#log
#next
37.1a 10

unix.superglobalmegacorp.com

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