I want to initialize an array of variable length with random zeros and ones. My problem is that the array I created seems to only have a length of 4 elements. Why is that?
int main()
{
int i, j;
int length = 20;
int *array = (int *) calloc(length, sizeof(int));
for (i = 1; i < length; i++) {
array[i] = 1;
printf("%d", array[i]);
}
printf("\n");
for (j = 0; j < sizeof(array); j++) {
printf("%d", array[j]);
}
getchar();
}