
Untitled
By: a guest on
Apr 25th, 2012 | syntax:
None | size: 0.79 KB | hits: 7 | expires: Never
Accessing elements in a static array using pointer(arithmetic) in C
int A[5][5];
int i; int j;
for(i=0;i<5;i++){
for(j=0;j<5;j++){
A[i][j]=i+j;
printf("%dn", A[i][j]);
}
}
*(A+(2*5+2)*sizeof(int))?
*(*(A + 2) + 2)
a[i][j] == *(a[i] + j) == *(*(a + i) + j)
T *p;
int I = 0;
float F = 0;
double D = 0;
int* PI = 0;
float* PF = 0;
double* PD = 0;
cout<<I<<" "<<F<<" "<<D<<" "<<PI<<" "<<PF<<" "<<PD<<endl;
I++;F++;D++;PI++;PF++,PD++;
cout<<I<<" "<<F<<" "<<D<<" "<<PI<<" "<<PF<<" "<<PD<<endl;
cout<<I<<" "<<F<<" "<<D<<" "<<(int)PI<<" "<<(int)PF<<" "<<(int)PD<<endl;
0 0 0 0 0 0
1 1 1 0x4 0x4 0x8
1 1 1 4 4 8
void* V = 0;
int* IV = (int*)V;
float* FV = (float*)V;
double* DV = (double*)V;
IV++;FV++;DV++;
cout<<IV<<" "<<FV<<" "<<DV<<endl;
0x4 0x4 0x8