home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_09
/
1109116a
< prev
next >
Wrap
Text File
|
1993-07-13
|
574b
|
30 lines
/* array8.c: Uses a pointer to a 1-d array */
#include <stdio.h>
main()
{
int a[][4] = {{0,1,2,3},{4,5,6,7},{8,9,0,1}};
int (*p)[4] = a; /* Pointer to array of 4 ints */
int i, j;
size_t nrows = sizeof a / sizeof a[0];
size_t ncols = sizeof a[0] / sizeof a[0][0];
printf("sizeof(*p) == %u\n",sizeof(*p));
for (i = 0; i < nrows; ++i)
{
for (j = 0; j < ncols; ++j)
printf("%d ",p[i][j]);
putchar('\n');
}
return 0;
}
/* Output
sizeof(*p) == 8
0 1 2 3
4 5 6 7
8 9 0 1
*/