====== Arrays as function arguments ====== /* arrays are always call by reference */ #include void f(int a[]) // implicitly converted to int *a { printf("\n"); printf("function: size of array : %d (worng)\n", sizeof(a)); // 8 printf("function: size of an element : %d\n", sizeof(a[0])); // 4 printf("function: number of elements : %d (wrong)\n", sizeof(a) / sizeof(a[0])); // 2 } int main() { int a[] = {1, 2, 3, 4, 5}; printf("\n"); printf("main: size of array : %d\n", sizeof(a)); // 20 printf("main: size of an element : %d\n", sizeof(a[0])); // 4 printf("main: number of elements : %d\n", sizeof(a) / sizeof(a[0])); // 5 f(a); return 0; } /* arrays are always call by reference */ /* arrays convert to pointers when pass to functions as arguments */ #include void show(int a[], int s) { int i; for(i=0; i