Pointer in C Language

Pointer

Pointer is a variable which used to store address of another variable.

Two operators are used in pointer:
(1.) & : It is pronounced as "Address of".
(2.) * : It is pronounced as "Value at address".
The "value at address" operator is also called "indirection" operator.

%u: It is used to print "address".

Syntax

data-type *variableName;

example:
int *p ;


Print the address of variable

In below program p variable holds 100.

&m returns the "Address of m".

%p prints the address of m.

*(&m) returns same value as m.

See Output

pointer type variable example 1

In below program ptr is pointer type variable.

"ptr = &v;" means ptr contains "address of v". Now ptr using in program means we are using address of v. And *ptr using in program means we are using value of v.

See Output

pointer type variable example 2

See Output

Double pointer( pointer to pointer )

Double pointer contains address of pointer type variable.

In below example **ptr2 is double pointer variable.
Example
int m = 100;
int *ptr1;
int **ptr2;

In below program ptr1 contains address of v and ptr2 contains address of ptr2.

See Output

In below program, If we are using *ptr1 in program means we are using value of v and we are using **ptr2 means we are using value of v.

See Output

See Output

About Us

Comsysapp.com is an educational website. Students and software developers can learn programming language tutorials. Comsysapp is very useful for beginners and professional developers. Comsysapp provides tutorial in easy language. Comsysapp.com has focus on simplicity.

Services

Comsysapp.com provides free tutorials like c, html, css, etc. All tutorials are free for beginner and professionals.


Terms of Use

comsysapp.com is not responsible for any mistake. We are not responsible if information made available on our website is incomplete or invalid. But comsysapp.com always try for zero-zero mistake.

Privacy policy

comsysapp.com does not collect any data from users. We use Google AdSense advertising on our website. We never ask personal or private information.


Sitemap

sitemap

copyright © 2023