How define an array of function pointers in C

前端 未结 5 1584
野趣味
野趣味 2020-11-28 02:05

I\'ve a little question. I\'m trying to define an array of function pointers dynamically with calloc. But I don\'t know how to write the syntax. Thanks a lot.<

5条回答
  •  感动是毒
    2020-11-28 02:40

    typedef R (*fptr)(A1, A2... An);
    

    where R is the return type, A1, A2... An are the argument types.

    fptr* arr = calloc(num_of_elements,sizeof(fptr));
    

提交回复
热议问题