Professional Documents
Culture Documents
STATIC(AT
DYNAMIC(AT
COMPILE
RUNTIME)
TIME)
Eg. Static
MALLOC CALLOC Int a =5;
(MEMORY (CONTIGUOUS
ALLOCATION.) ALLOCATION.)
FREE(FREES REALLOC(M
PREVIOUSLY ODIFIES SIZE
ALLOCATED OF
SPACE.) PREVIOUSLY
ASSIGNED
SPACE.)
POINTER AND ONE DIMENSIONAL
ARRAY
The array declared as: static int x[5]={1,2,3,4,5};
Is stored as follows:
Clrscr();
For(i=0;i<2;i++)
for(j=0;j<3;j++)
We can declare an array that contains pointers as its ARRAY OF POINTER
Elements. Every element of this array is a pointer variable that can hold address of
any variable of appropriate type.
Syntax: data_type*array name[size];
#include<stdio.h>
#include<conio.h>
Void main()
{ int*a1[5],i,a=10,b=20,c=30,d=40,e=50;
a1[0]=&a;
Output:
a1[1]=&b; 15
a1[2]=&c; 65514
a1[3]=&d; 25
65512
a1[4]=&e; 35
For(i=1;i<5;i++) 65510
{ *a1[i]=*a1[i]+5; 45
65508
printf(“%d”,*a1[i]); 55
printf(“%u”,a1[i]); 65506
}
getch();
Pointer to pointer
pointer is a variable that can contain memory address.this pointer
takes some space in memory and hence it also has an address.we can
store the address of a pointer variable in some other variable,which
is known as a pointerOutput:
to pointer variable.
#include<stdio.h> address of i=65522
#include<conio.h> address of i=65522
Void main() address of i=65522
address of j=65524
{
The value of i=3
Int *j,**k,i=3; The value of i=3
Clrscr();
J=&i;
K=&j;
Printf(“address of i =%u”,&i);
Printf(“address of i =%u”, j);
Printf(“address of i =%u”,*k);
Printf(“address of j =%u”, &j);
Printf(“the value of i =%d”,**k);
Printf(“the value of i =%d”,*j);
getch();
}
Pointer and
functions