What is a pointer in C?

A pointer is a variable that refers to the address of a value. It makes the code optimized and makes the performance fast. Whenever a variable is declared inside a program, then the system allocates some memory to a variable. The memory contains some address number. The variables that hold this address number is known as the pointer variable.

For example:

  1. Data_type *p;

The above syntax tells that p is a pointer variable that holds the address number of a given data type value.

Example of pointer

  1. #include <stdio.h>
  2. int main()
  3. {
  4.    int *p; //pointer of type integer.
  5.    int a=5;
  6.    p=&a;
  7.    printf(“Address value of ‘a’ variable is %u”,p);
  8.     return 0;
  9. }



Address value of 'a' variable is 428781252