Category Archives: Pointer

Details about Pointer




A good example of pointer code at Hacker Rank

A good example of pointer code at Hacker Rank:


C++ Pointer

I tried to clear here my logic for pointer basic


Actually in c++ pointer can be declare like this

type  *var_name;


int *ip;
double *dp;
float *fp;
char *ch;


C++ NULL Pointers

It actually represent no where

int *zaki=0;
int *dhaka=NULL;

Both the examples meaning the same attitude of the c++

It actually default by the operating systems

Here is one example:

We can also define by this

if(ptr) //it will proceed if p is not null
if(!ptr) //it will proceed if p is null

Pointer arithmetic

Incrementing a pointer:

Decrementing a pointer:

Comparison with pointer:


C++ pointer vs arrays:

C++ Array of pointers

and also can store data like this with pointer and array mutually

C++ Pointer to Pointer:



What is pointer?
Pointer is actually a variable which points to another variable by address not value

notation is simple just a asterisk before the variable name


int live=20;
int *zaki=&live; //here i am pointing *zaki to a variable address of live
so *zaki is a pointer

now we want to print what actually shows

if we write these line
printf(“zaki = %d”,*zaki);

Output will be: 20 //the value of live

And if we print
printf(“zaki = %d”,zaki);
Output will be: 2686744 //the address of memory location of  the variable live

Another example from subeen vaia’s book: