× Home Introduction Structure of program Variables and keywords Constants Data Types Operators Statements Functions Storage Classes Array Structure Pointer Union Strings Header Files
☰ Topics

Pointer

Pointer is a variable which holds the memory address of annother variable. Pointers are represented by '*'. It is derive data type in C. Pointer returns the value of stored address.

Syntax:

  

< data_type > *pointer_name;

In above syntax,

* = variable pointer_name is a pointer variable.

pointer_name requires memory location

pointer_name points to a variable of type data type.

How to Use?

int *tot;

Illustration:

int tot = 95

Figure:

In above example, the statement instructs the system to find out a location for integer variable quantity and puts the values 95 in that memory location.

Features of pointer:

  

#include< stdio.h > #include< conio.h > void main() { int a = 10; int *ptr; clrscr(); ptr = &a; printf("\n\tValue of a : %d", a); scanf("\n\n\t Value of pointer ptr : %d", *ptr); printf("\n\n\t Address of pointer ptr : %d", ptr); getch(); } output: Value of a : 10 Value of pointer ptr : 10 Address of pointer ptr : -12

Next Topic ➤