#include <stdio.h>
#include <stdlib.h>
#define ROW 4
#define LEN 5
char array[ROW][LEN] = {
{'P', 'I', 'C', '1', '6'},
{'P', 'I', 'C', '1', '8'},
{'P', 'I', 'C', '2', '4'},
{'D', 'S', 'P', 'I', 'C'}
};
char *ptr = &array;
unsigned char row, column;
int main(void)
{
printf("access using array method\n");
for(row = 0; row < 4; row++)
{
for(column = 0; column < 5; column++)
{
printf("%c", array[row][column]);
}
printf("\n");
}
printf("----------------------------------\n");
printf("access using array method\n");
for(row = 0; row < ROW; row++)
{
for(column = 0; column < LEN; column++)
{
printf("%c", *ptr++);
}
printf("\n");
}
printf("access using array + pointer method\n");
for(row = 0; row < 4; row++)
{
for(column = 0; column < 5; column++)
{
printf("%c", *(array[row] + column));
}
printf("\n");
}
printf("----------------------------------\n");
printf("access using pointer method\n");
for(row = 0; row < 4; row++)
{
for(column = 0; column < 5; column++)
{
printf("%c", *(*(array+row)+column));
}
printf("\n");
}
printf("----------------------------------\n");
printf("access using ptr point to array method\n");
for(row = 0; row < 4; row++)
{
for(column = 0; column < 5; column++)
{
printf("%c", *(ptr + (row * 5) + column));
}
printf("\n");
}
while(1)
{
}
system("pause");
return 0;
}