使用函数指针数组和切换之间是否有任何区别。 ı编写了这样的代码
// Declaritons of add-substract-multiply funcitons
void (*fun_ptr_arr[])(int,int) = {add,subtract,multiply};
unsigned int ch,a = 15,b = 10;
printf("Enter Choice: 0 for add,1 for subtract and 2 "
"for multiply\n");
scanf("%d",&ch);
if (ch > 2) return 0;
(*fun_ptr_arr[ch])(a,b);
,我想知道这段代码或使用开关会更好吗? (以效果为准)