2 ms·
Wow, that's new to me! Like a macro in languages I'm used to, but smarter. This is key in contextualizing the "it's a pointer" part of the explanation. It sound
by happytoexplain 2y ago
Wow, that's new to me! Like a macro in languages I'm used to, but smarter. This is key in contextualizing the "it's a pointer" part of the explanation. It sounds like the size of an array is never intrinsic to it, as a data type, regardless of whether what we've got is a pointer. What's important is that sizeof is compile-time, so it can only know the array size in contexts where it can be determined at compile time.
- kstrauser 2y agoYep, that’s correct. The entire data structure of a C array, as available to the running code, is a pointer to the first element. The compiler has that information during compilation but it doesn’t make it trough to the resulting executable.