// // main.cpp // FunctionPointers // // Created by Robert Metcalfe on 16/05/13. // Copyright (c) 2013 Robert Metcalfe. All rights reserved. // // // main.cpp // FunctionPointers // // Created by Robert Metcalfe on 16/05/13. // Copyright (c) 2013 Robert Metcalfe. All rights reserved. // #include #include char* function1(int passedarg1, double passedarg2, long passedarg3) { char* retc = (char*)malloc(11); sprintf(retc, "%d", passedarg1); return retc; } char* function2(int passedarg1, double passedarg2, long passedarg3) { char* retc = (char*)malloc(11); sprintf(retc, "%lf", passedarg2); return retc; } char* function3(int passedarg1, double passedarg2, long passedarg3) { char* retc = (char*)malloc(11); sprintf(retc, "%ld", passedarg3); return retc; } int main(int argc, const char * argv[]) { char* (*funcArr[3])(int, double, long) = {&function1, &function2, &function3}; for (int i=1; i<=3; i++) printf("%s\n", funcArr[i-1]((int)i, (double)(i+1)+0.1, (long)(i+2))); return 0; }