Pointer in c++

In C language, a pointer is a variable that points to or references a memory location in which data is stored. Each memory cell in the computer has an address which can be used to access its location.  A pointer variable points to a memory location. By making use of pointer, we can access and change the contents of the memory location.    

A pointer is a variable which contains the address in memory of another variable. We can have a pointer to any variable type.

The unary or monadic operator & gives the ``address of a variable''.

The indirection or dereference operator * gives the ``contents of an object pointed to by a pointer''.

To declare a pointer to a variable do:

int *pointer;

Example:-

int x = 1, y = 2;

int *ip;

ip = &x;

y = *ip;

x = ip;

*ip = 3;       

Example:-

/* A program to illustrate pointer declaration */ 

main() 

int *ptr; 

int sum; 

sum=45; 

ptr=∑

cout<<"\n sum variable value is "<<sum; 

cout<<"\n The 'ptr' pointer variable value is "<<ptr; 

}

You may also like

What is PHP?

PHP stands for PHP: Hypertext pre-processor, with that PHP standi...

What is ASP.NET?

ASP.NET, the next version of ASP, is a programming framework used...

What is Data Structure?

A data structure is a group of data elements grouped together und...

What is C#?

C# removes some of the complexities and pitfalls of languages suc...

What is Math?

Math is no Definition it has only Calculation.Closure Property of...

What is Oracle?

Based in Redwood, California, Oracle Corporation is the largest s...

Function in java

A function in Java language is a block of code that performs a sp...

Do-While Loop in java

The do-while loop looks like this:do{ this ; and this ; and this ...