A pointer variable which stores base address (memory address of 1st element) of a 2D array is called pointer of 2D array.
एक पॉइंटर वेरिएबल जो 2D अरे का बसे एड्रेस रखता है पॉइंटर ऑफ़ 2D अरे कहलाता है।
Syntax :-
data_type array_name[row_size][column_size],*pointer_name;
pointer_name=&array_name[0][0];
C program for pointer of 2D array
#include<stdio.h>
#include<conio.h>
void main(){
int mat[3][3]={2,4,5,1,0,1,3,7,3},*p;
p=&mat[0][0];
printf("Accessing 2D array mat through pointer p\n");
for( i=0;i<3;i++){
for(j=0;j<3;j++){
printf("%d",*p++);
}
printf("\n");
}
getch();
}
No comments:
Post a Comment