#include #include void cap_string(char* s) { for( ; *s; s++) *s = toupper(*s); } void print_stretched(char *s){ for( ; *s; s++) printf("%c ", *s); printf("\n"); } void print_doubled(char *s){ printf("%s%s\n", s, s); } struct string_operations { void (*capitalize)(char *); void (*print_nice)(char *); }; void cap_and_print(char *s, struct string_operations *ops){ ops->capitalize(s); ops->print_nice(s); } int main(){ struct string_operations ops_a = {cap_string, print_doubled}; struct string_operations ops_b = {cap_string, print_stretched}; char s1[] = "foxes have holes"; char s2[] = "There was a fox living under my friend's porch"; cap_and_print(s1, &ops_a); cap_and_print(s2, &ops_b); return 0; }