Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Should you dereference function pointers?

Name: Anonymous 2009-11-04 19:33

#include <stdio.h>

void func() {
  printf("hello world\n");
}

void (*go)() = func;

int main() {
  go();    // number 1...
  (*go)(); // or number 2
  return 0;
}


Which is correct ANSI C89? GCC accepts both, even in -ansi -pedantic; it outputs hello world twice.

Name: Anonymous 2009-11-05 19:50

>>17
That is actually a way to make pointer arithmetic on arrays a lot less obtuse.

int *p3 = &array[4]

is easier to read and faster to type than

int *p3 = array + (sizeof(int) * 4)

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List