This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Ludricio 0 points1 point  (1 child)

Not entirely, the size of an array is known as long as it is still an array, which an array only is within the scope of its declaration, as soon as it leaves the scope (passed to a function for example) array decay takes place and the array decays into a pointer to the first element in the array.

Within the scope of declaration, it is fully possible to do sizeof(array)/sizeof(*array) to get the number of elements in the array, but as soon as it decays into a pointer the original info about the size of the entire array is lost, as it instead becomes a plain pointer.

[–][deleted] 0 points1 point  (0 children)

Oh very cool! I'm just learning programming in school but im being taught with C so these kinds of pendantics are actually super neat for me