Professional Documents
Culture Documents
Defn
Examples
(only pseudo code-for concept)
1.
int a=10;
int b;
b=a;
b=&a;
wrong----
So Weve-----
int *b;
b=&a;
2.
Int a=10;
Int *p; p is a pointer which points an integer type
variable or,p is
pointer to an integer. * is indirection operator
P=&a;
p is pointing as value. Or, p stores address
of a
or,value stored at p=address of a.
& is address operator.
Note----a is direct addressing
*p is indirect addressing(*p=value at address stored at p)
10
100
0
*p
3.
int a=10;
char *p;
p=&a;wrong
4.
Int a=10;
Char *P;
P=(char*)&a;
Printf(%d,&p);
5.
Only address stored in pointer ,not values
Int a=10;
Int *p;
P=a;wrong(although true in c compiler considering
value as address)
6.
Int a=10;
Int *p;
*p=a;(wrongsometm run time error)
1
0
605
8
7.
Int a=10;
Int *p=null;(0th address in memory is reserved in o/s as
null)
*p=a;//dereferencing
Note-although this is not 100% correct but safe almost.
So,dereference only when addressed while declaring..
8.
int *p;
p=(int *)7000; //a no. is made like address by
typecasting
but problem may occur if address 7000 is engaged
somewhere
becoz, by default a value cant be address.
9.
Int *p;
P=7000;
10.
Int *p;
P=&7000;
11.
Pointer never points itself
Int *p;
P=&p;(wrong)
12.
Int a=10;
Int *p;
Int *q;
p=&a;
q=&p;(wrong)
notepointer is backbone of c.
because of this c is still more popular.
Most of the work associated to virus/antivirus were performed
with the help of pointers.(advance c)