
1 /*------------------------------ 2 func_ptr.c -- 使用函数指针 3 ------------------------------*/ 4 5 #include <stdio.h> 6 #include <string.h> 7 #include <ctype.h> 8 9 #define LEN 81 10 11 char* s_gets(char *st, int n); 12 char showmenu(void); 13 void eatline(void); //读取至行末尾 14 void ToUpper(char*); //把字符串转换为大写 15 void ToLower(char*); //把字符串转换为小写 16 void Transpose(char*); //大小写转换 17 void Dummy(char*); //不更改字符串 18 void show(void (*fp)(char*), char *str); 19 20 21 int main() 22 { 23 char line[LEN], copy[LEN]; 24 char choice; 25 void (*pfn)(char*); //声明函数指针 26 27 puts("Enter a string (empty line to quit):"); 28 29 while (s_gets(line, LEN) != NULL && line[0] != '