Wednesday 5 August 2015

Pointers in C

C language has become popular because of pointers. Pionters are introduced first in C.

Pointer is a special type of variable which stores the address of the variable of similar data type.

Whereas the normal variable will store only values. Every pointer will occupy equal amount of memory(2 or 4 bytes), because it stores only the address and address is always a numeric value.

The memory a program uses  is divided into four different areas:

i. The code area, where the compiled program sits in memory.
ii. The global  area , where global variables are stored.
iii. The heap, where dynamically allocated variables are allocated from.
iv. The stack, where parameters and local variables are allocated from.

Pointers can be used with a normal variable , arrays , functions structures. 

Using pointers we can achieve 

i. Dynamic memory allocation
ii. Call be reference.

Using pointers we can make a function to return more than one value.

Pointer plays a very important role in creating trees and graphs , where we use self-referential structuresFor developing those applications.

----------------------------------------------------------------
Article By:
Kaja Masthan
Assistant Professor
CSE Department
Sphoorthy Engineering College

Sphoorthy Engineering College




No comments:

Post a Comment