How would I declare a as a array of 4 pointers to functions with no parameters and which return void? The pointers originally point to functions with names: insert, search, update, and print.
This is the closest I can get to the declaration:
void (*a[4]) () {insert,search,update,print}
In ISO C18, the line
will declare an array of 4 elements in which each element is a pointer to a function returning
voidthat takes an unspecified number of arguments. If you want to specify that the functions to take no arguments, then you must write(void)instead of():However, in the upcoming ISO C23, this is no longer necessary, as specifying a function with an unspecified number of arguments is no longer possible (except for variadic functions). In C23, it is therefore sufficient to write
()instead of(void). This also applies to ISO C++.Also, if you want to initialize the array, you must use
=, like this:In C++, the
=is not necessary during initialization, but it is necessary in C (both in C18 and C23).