Q:

Why is the initialization of p legal but that of lp illegal?

0

Why is the initialization of p legal but that of lp illegal?

int i = 42;        void *p = &i;         long *lp = &i;

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

int main() {
  int i = 42;
  void *p = &i;   // OK, a `void *` pointer can point to any type
  //long *lp = &i;  // Error, a `long *` pointer can not point to `int *`

  return 0;
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now