0% found this document useful (0 votes)
9 views2 pages

Pointers

Uploaded by

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

Pointers

Uploaded by

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

Pointers

----------
int a;
a=10;

float b;
b=12.33;

* A Pointer is a variable which stores the address of another variable.


* Pointers are declared with a leading star (*).
* To store the address of any variable, use the & symbol (it is an address
operator).

Syntax of declaring a pointer


----------------------------------
data-type *variable-name;

int *p;

where p is a pointer variable of type integer. That means it stores the address of
an integer variable.

* Unlike the normal variables, pointers are designed for taking addresses.

Initializing pointers
-----------------------
To initialize the pointer, use & the symbol, called address operator.

Syntax:
--------
data-type *pointer;
pointer=&variable-name;

for eg:
--------
int a=100;
int *p; /* p is an integer pointer */
p=&a; /* initializing the pointer */

p takes the address of the integer variable a.

* Because pointers representing address, getting the value of that address is very
fast.

* Though pointers stores the address, when the pointer is referenced it gives the
value of that address.

/* Prg on pointers */
#include <stdio.h>
#include <conio.h>
void main()
{
int a=100,*p;
/* p is an integer pointer */
clrscr();
p=&a; /* initialization of the pointer */
printf("The Value of a is %d\n",a);
printf("The Value of a is %d\n",*p);
printf("The Address of a is %u\n",&a);
printf("The Address of a is %u\n",p);
getch();
}

output
--------
The Value of a is 100
The Value of a is 100
The Address of a is 65345
The Address of a is 65345

You might also like