Pointers in C Programming

Pointer is a variable which holds the memory address of another variable. Pointers are represented by ‘*’. It is a derive data type in C. Pointer returns the value of stored address.
Syntax:

	 *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 :

* Pointer variable should have prefix ‘*’.
* Combination of data types is not allowed.
* Pointers are more effective and useful in handling arrays.
* It can also be used to return multiple values from a funtion using function arguments.
* It supports dynamic memory management.
* It reduces complexity and length of a program.
* It helps to improve execution speed that results in reducing program execution time.

Program :

/*  Program to demonstrate pointer.
Creation Date : 10 Nov 2010 11:41:20 PM
Author :www.technoexam.com [Technowell, Sangli] */

#include <stdio.h>
#include <conio.h>

int main(void)
{
	int a=10;
	int *ptr;
	clrscr();
	ptr = &a;
	printf("\n\t Value of a : %d", a);
	printf("\n\n\t Value of pointer ptr : %d", *ptr);
	printf("\n\n\t Address of pointer ptr : %d", ptr);
	getch();
	return 0;
}

Output :

	Value of a : 10
	
	Value of pointer ptr : 10
	
	Address of pointer ptr : -12_

Leave A Comment

Your email address will not be published. Required fields are marked *