0

Just a minimum working example:

#include <stdio.h>

void foo(char* str)
{
    printf("%s\n", str);
}

main()
{
   foo("foo");
   (* foo)("* foo");
}

which outputs

foo
* foo

I thought the function name should be the address of the routine in the code segment, so the star operator should return an executable instruction. But how does this operator work here actually? Thanks for shedding some light.

Guo
  • 3
  • 1
  • 2

1 Answers1

0

In C, functions are not values, you cannot "dereference a pointer to a function" and get something (a value) that makes sense.

Therefore, trying to dereference and call such a pointer has no additional effect, it's the same as calling through the pointer in the first place.

unwind
  • 391,730
  • 64
  • 469
  • 606