home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
listings
/
v_11_09
/
1109113a
< prev
next >
Wrap
Text File
|
1993-07-13
|
767b
|
44 lines
/* array5.c: Arrays as parameters */
#include <stdio.h>
void f(int b[], size_t n)
{
int i;
puts("\n*** Entering function f() ***");
printf("b == %p\n",b);
printf("sizeof(b) == %d\n",sizeof(b));
for (i = 0; i < n; ++i)
printf("%d ",b[i]);
b[2] = 99;
puts("\n*** Leaving function f() ***\n");
}
main()
{
int i;
int a[] = {0,1,2,3,4};
size_t n = sizeof a / sizeof a[0];
printf("a == %p\n",a);
printf("sizeof(a) == %d\n",sizeof(a));
f(a,n);
for (i = 0; i < n; ++i)
printf("%d ",a[i]);
return 0;
}
/* Output
a == FFEC
sizeof(a) == 10
*** Entering function f() ***
b == FFEC
sizeof(b) == 2
0 1 2 3 4
*** Leaving function f() ***
0 1 99 3 4
*/