Skip to main content

Posts

Showing posts with the label types of pointer

Types of pointers

Types of pointers NULL pointer if a pointer does not point to any variable, it can be initialized to NULL to indicate that it does not hold any valid address.  Example: int *ptr=NULL;  Dangling pointer  A pointer which holds the address of a variable which no longer exists, is a dangling pointer. Example:  void main()  { int *ptr;  { int num=10;  ptr=#  } //num is destroyed  //ptr is still holds address of num so it is dangling pointer.  } Generic/void pointer A pointer which points to ‘void’ data type is called a generic pointer. In ‘C’, void represents the absence of type, so void pointers are pointers that point to a value that has no type. This allows void pointers to point to any data type.  Example:  void *ptr;  (int *)ptr=&n;  Uninitialized/wild pointer A pointer which has not been assigned any address till it is first used in a program is called an uninitialized or wild pointer. It contains some ga...