Declaring and Initializing Pointers in C

  • int *p; // p contains address of an int
  • float *x // x contains address of a float
  • p = &quantity // quantity is an int variable
  • p = &f where f is float is an erroneous statement, because *p results in a wrong ans
  • int x, *p = &x; // initializes p to address of x
  • int *p=&x, x is invalid

No comments:

Post a Comment