What does int (* func) () do in C?

What does this line do in C?

 int (*func)();

I extracted it from the following program, which should execute byte code (assembly instructions are converted to corresponding bytes)

char code[] = "bytecode will go here!";
int main(int argc, char **argv)
{
  int (*func)();
  func = (int (*)()) code;
  (int)(*func)();
}
+4
source share
2 answers

The string in question declares a pointer to a function with undefined arguments (an "obsolete" function with C99) and with a return type int.

The first line of your maindeclares this pointer, the second line initializes the pointer so that it points to a function code. The third line executes it.

You can get a description of function pointers in general here .

+4
source

int (*func)(); func , int .

+2

All Articles