I know this question has been asked before, but my question is more specific, here is the code:
#include <stdio.h>
#include <time.h> /* must be included for the time function */
main()
{
time_t t = time(NULL);
srand((unsigned) t);
int i = rand();
int a[i];
printf("%d\n", i);
printf("%d\n", sizeof a);
}
I compiled this code using the gcc and -ansi options to limit it to ANSI C recognition only. I know that the compiler could not know the size of the array at compile time because it was accidentally determined at runtime. Now my question is - is the value returned by sizeof just a random value or does it make sense?
source
share