home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
VRAC
/
CUJ0993.ZIP
/
1109110A
< prev
next >
Wrap
Text File
|
1993-07-13
|
650b
|
31 lines
/* array1.c: Uses an array name as a pointer */
/* NOTE: Pointers and ints are 2-bytes in all examples */
#include <stdio.h>
main()
{
int a[] = {0,1,2,3,4};
int *p = a;
printf("sizeof a == %d\n",sizeof a);
printf("sizeof p == %d\n",sizeof p);
printf("p == %p, &a[0] == %p\n",p,&a[0]);
printf("*p == %d, a[0] == %d\n",*p,a[0]);
p = a + 2;
printf("p == %p, &a[2] == %p\n",p,&a[2]);
printf("*p == %d, a[2] == %d\n",*p,a[2]);
return 0;
}
/* OUTPUT
sizeof a == 10
sizeof p == 2
p == FFEC, &a[0] == FFEC
*p == 0, a[0] == 0
p == FFF0, &a[2] == FFF0
*p == 2, a[2] == 2
*/