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.
- 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
- #include <stdio.h>
- int main()
- int *p; //pointer of type integer.
- int a=5;
- printf(“Address value of ‘a’ variable is %u”,p);
- return 0;
Address value of 'a' variable is 428781252