#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef int (*calculate_sum_fun)(int a, int b);
typedef struct handle_t {
calculate_sum_fun calculate_sum;
} handle_t;
int add(int a, int b)
{
return (a + b);
}
int main(void)
{
struct handle_t *handle = NULL;
int result = -1;
handle = (struct handle_t*)malloc(sizeof(struct handle_t));
if(handle == NULL){
printf("memory alloc failed!!!\n");
return -1;
}
memset(handle, 0, sizeof(struct handle_t));
handle->calculate_sum = add;
if(handle->calculate_sum != NULL){
result = handle->calculate_sum(100, 20);
printf("result is %d\n", result);
}
return 0;
}