hai,
i have a doubt.will you please explain me the use of static in the below snippets?what happens if we dont use static?
output:
error
output:
error
output:
2000
1000
1
output:
2000
1000
1
note:
assuming the starting address of array a as 1000 and assuming the starting address of pointer array p as 2000
this is the output i get in my compiler.
thanks for your reply on advance.
i have a doubt.will you please explain me the use of static in the below snippets?what happens if we dont use static?
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5]={1,2,3,4,5};
int *p[5]={a,a+1,a+2,a+3,a+4};
clrscr();
printf("%d\n%d\n%d",p,*p,**p);
getch();
}
error
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
int a[5]={1,2,3,4,5};
static int *p[5]={a,a+1,a+2,a+3,a+4};
clrscr();
printf("%d\n%d\n%d",p,*p,**p);
getch();
}
error
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
static int a[5]={1,2,3,4,5};
static int *p[5]={a,a+1,a+2,a+3,a+4};
clrscr();
printf("%d\n%d\n%d",p,*p,**p);
getch();
}
2000
1000
1
Code:
#include<stdio.h>
#include<conio.h>
void main()
{
static int a[5]={1,2,3,4,5};
int *p[5]={a,a+1,a+2,a+3,a+4};
clrscr();
printf("%d\n%d\n%d",p,*p,**p);
getch();
}
2000
1000
1
note:
assuming the starting address of array a as 1000 and assuming the starting address of pointer array p as 2000
this is the output i get in my compiler.
thanks for your reply on advance.
Comment