The sizeof
operator is a compile time operator but in the program below it is changing at run time.
#include <stdio.h>
void func (int i) {
int a[i];
printf("%d \n", sizeof(a));
}
main() {
int i = 0;
while(i <= 5) {
func(i);
i++;
}
}
memory will be allocated at runtime. how the compiler will calculate structure size with out structure padding?
Your information is outdated. a
is a variable-length array; for those, sizeof
is determined at runtime. Variable-length arrays are a C99 feature that did not exist when the source of your information was written.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With