Home / Questions / What is a pointer in C?
Explanatory Question

What is a pointer in C?

👁 780 Views
📘 Detailed Answer
🕒 Easy to Read
Read the answer carefully and go through the related questions on the right side to improve your understanding of this topic.

Answer with Explanation

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:

 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;  
   p=&a;  
   printf("Address value of 'a' variable is %u",p);  
    return 0;  
}  

Output

Address value of 'a' variable is 428781252