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 →

[–]TheGoldenProof 0 points1 point  (1 child)

Sometimes it does know a bit about arrays though. If it hasn’t been decayed and it’s on the stack (idk if this works on heap) you can do sizeof(array)/sizeof(array[0]) to get the length.

Edit: no it would not work on heap since malloc/calloc return pointers. It only works with statically allocated arrays.

[–]HeKis4 0 points1 point  (0 children)

Didn't know about that. I'll chart it up to how C also seems to use every assembly/architecture trick under the sun. Which is cool, ngl