Exercise 14. Writing and Using Functions

Up until now, we’ve just used functions that are part of the stdio.h header file. In this exercise, you’ll write some functions and use some other functions.

ex14.c

 1   #include <stdio.h>  2   #include <ctype.h>  3  4   // forward declarations  5   int can_print_it(char ch);  6   void print_letters(char arg[]);  7  8   void print_arguments(int argc, char *argv[])  9   { 10       int i = 0; 11 12       for (i = 0; i < argc; i++) { 13           print_letters(argv[i]); 14       } 15   } 16 17   void print_letters(char arg[]) 18   { 19       int i = 0; 20 21       for (i = 0; arg[i] != '\0'; i++) { 22           char ch = arg[i]; 23 24           if (can_print_it(ch)) { 25               printf ...

Get Learn C the Hard Way: A Clear & Direct Introduction To Modern C Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.