/* Decorations.c (c) Kari Laitinen http://www.naturalprogramming.com/ 2013-11-26 File created. 2013-11-26 Last modification. */ #include void multiprint_character( char character_from_caller, int number_of_times_to_repeat ) { int repetition_counter = 0 ; while ( repetition_counter < number_of_times_to_repeat ) { printf( "%c", character_from_caller ) ; repetition_counter ++ ; } } void print_text_in_decorated_box( char text_from_caller[] ) { int text_length = strlen( text_from_caller ) ; printf( "\n " ) ; multiprint_character( '=', text_length + 8 ) ; printf( "\n " ) ; multiprint_character( '*', text_length + 8 ) ; printf( "\n **" ) ; multiprint_character( ' ', text_length + 4 ) ; printf( "**\n ** %s **\n **", text_from_caller ) ; multiprint_character( ' ', text_length + 4 ) ; printf( "**\n " ) ; multiprint_character( '*', text_length + 8 ) ; printf( "\n " ) ; multiprint_character( '=', text_length + 8 ) ; printf( "\n " ) ; } int main() { char first_text[] = "Hello, world." ; print_text_in_decorated_box( first_text ) ; print_text_in_decorated_box( "I am a computer program written in C.") ; } /* This program produces the following output: ===================== ********************* ** ** ** Hello, world. ** ** ** ********************* ===================== ============================================= ********************************************* ** ** ** I am a computer program written in C. ** ** ** ********************************************* ============================================= */