Fairly easy pointer increment program is as follows.
#include<stdio.h>
int main(){
int i,a[10],*p=a;
for (i=0; i<10; i++,p++){
printf("\nAddress of a[%d] is %d",i,p);
}
getch();
return 0;
}
Here is output:
Address of a[0] is 2293488
Address of a[1] is 2293492
Address of a[2] is 2293496
Address of a[3] is 2293500
Address of a[4] is 2293504
Address of a[5] is 2293508
Address of a[6] is 2293512
Address of a[7] is 2293516
Address of a[8] is 2293520
Address of a[9] is 2293524
It's suppose to increment address by 2 Bytes, but actually its incrementing to 4 Bytes. Did standard size for Integer changed to 4 Bytes ? OR Am I missing something ?