Relation between Pointers and Functions in C

Relation between Pointers and Functions

  • Passing a pointer to a function is known as call by reference and function works on actual variables in that case
  • void copy(char *s1, char*s2) { while ((*s1++ = *s2++) != ‘\0’ }
  • Pointer parameters are very common in string functions like above
  • *s++ and *++s are different!
  • type (*ptr)() is a pointer to a function with return type as type
  • It is different than type *ptr()
  • double (*p1)(), mul();
  • p1 = mul;
  • (*p1) (x,y) is same as mul(x,y)
  • It is used in system programming

No comments:

Post a Comment