0% found this document useful (0 votes)
13 views3 pages

Pointer

The document discusses pointers in C including definition, declaration, operators, and initialization. A pointer is a variable that stores the address of another variable. Pointers are declared using a datatype and asterisk. The indirection and address of operators are used with pointers. Pointers are initialized by assigning the address of a variable. An example demonstrates pointer usage.

Uploaded by

Pavankumar Bhise
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Pointer

The document discusses pointers in C including definition, declaration, operators, and initialization. A pointer is a variable that stores the address of another variable. Pointers are declared using a datatype and asterisk. The indirection and address of operators are used with pointers. Pointers are initialized by assigning the address of a variable. An example demonstrates pointer usage.

Uploaded by

Pavankumar Bhise
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Pointer

Definition
Declaration
Operators
Intialization

Definition

It is a special variable which holds address of


another variable of similar type.

Declaration

one can declare a pointer variable by using :

datatype * pointer-variable-name ;

datatype : It is basic datatype ( char , int , float , double )

* : It is an indirection operator (Asterisk) used to declare


pointer

pointer-variable-name : It is a valid name .

; It is delimiter which indicates end of declaration.


Example :

1) int * a;
a is pointer variable of type integer .

2) char * b;
b is pointer variable of type character.

3) double * c;
c is pointer variable of type double

iii) Operators in pointer

There are two operators used in pointers & they are :

i) * ( indirection operator )
It is used to declare pointer variable as well as it returns the
value of the refernced variable.

ii) & ( address of operator)


It is used to return address of a variable
Initialization of pointer

we can initialize a pointer variable as follows

int *a ; // pointer variable declaration


int b=5; // b is integer type variable with address 502

as per definition

a= &b ; // initialization of pointer

printf(“address of b = %p”,a); //502


if i have to access value of b through pointer then

*a= *(&b);
*a = value at (address of b)= 5

printf(“%d”,*a) ; // 5

WAP to show use of pointer


#include <stdio.h>

int main()
{
int *a; //ptr variable of type int
int b=456; // variable of type int

a=&b; // initialize pointer

printf("\n Address of b =%d",a);


printf("\n value of b=%d", *a);

You might also like