currently I'm doing book called "C Primer Plus" by Stephen Prata. I'm on chapter 10 it is about pointers and arrays.
Code looks like this
#include <stdio.h>
#define SIZE 10
long sum (int tab[], int n);
int main (void)
{
int balls[SIZE] = {20, 10, 5, 39, 4, 16, 19, 26, 31, 20};
long wynik;
wynik = sum(balls, SIZE);
printf("Number of balls is %ld, sizeof int = %ld\n", wynik, sizeof(int));
printf("Size of balls array is %zd bytes.\n", sizeof balls);
return 0;
}
long sum(int tab[], int n)
{
int i;
int suma = 0;
for (i = 0; i < n; i++)
suma += tab[i];
printf("Size of tab array is %d bytes\n", sizeof tab);
return suma;
}
Output:
Size of tab array is 8 bytes
Number of balls is 190, sizeof int = 4
Size of balls array is 40 bytes.
And my question is: why size of tab is 8 bytes, when size of int is 4 bytes?