main() { fpointer = add; /* Put the address of 'add' in 'fpointer' */ printf("%d \n", fpointer(4, 5)); /* Execute 'add' and print results */ fpointer = sub; /* Repeat for 'sub' */ printf("%d \n", fpointer(6, 2)); }
//Function for checking type of string. //Essentially compressed replacement for isX() char* single_to_str(char* src, int (*fpointer)(int)){ if(fpointer(*src)){ char* temp=malloc(sizeof(char)*1); int i=0; for(i=0;fpointer(*src);i++){ temp[i]=*src; temp=realloc(temp,sizeof(char)*i+1); src++; } temp[i]='\0'; return temp; } return 0; }