/* --------------------------------------------------------------------- ** Figure 13.12: A string parameter. ** --------------------------------------------------------------------- */ #include "tools.h" void print_upper( string s ); void main( void ) { char first[15]; string name = first; char street[30], city[30], state[3]; printf( " Enter first name: " ); scanf( "%14s", name ); /* read one word only */ printf( " Enter street address: " ); scanf( " %29[^\n]", street ); /* read to end of line */ printf( " Enter city, state: " ); /* split line at comma */ scanf( " %29[^,], %2[^\n]", city, state ); putchar( '\n' ); print_upper( name ); printf( "\n %s %s, ", street, city ); print_upper( state ); puts( "\n" ); } /* ---------------------------------------------------------------------- */ void print_upper( string s ) { int k; /* loop counter */ for ( k = 0; s[k] != '\0'; ++k ) putchar( toupper( s[k] ) ); }