summaryrefslogtreecommitdiff
path: root/usr.bin/learn/lib/C/L33.1a
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin/learn/lib/C/L33.1a')
-rw-r--r--usr.bin/learn/lib/C/L33.1a23
1 files changed, 23 insertions, 0 deletions
diff --git a/usr.bin/learn/lib/C/L33.1a b/usr.bin/learn/lib/C/L33.1a
new file mode 100644
index 00000000000..e421f55eb7c
--- /dev/null
+++ b/usr.bin/learn/lib/C/L33.1a
@@ -0,0 +1,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