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