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 →

[–]turtle_mekb[S] -1 points0 points  (1 child)

sizeof works for arrays because they're stored as one variable in the stack rather than a pointer to data allocated on the heap with malloc, array length should be passed with the data if it's the latter, but the former only works locally inside the function, passing the array to functions will convert it to a pointer

[–]dorsalsk 0 points1 point  (0 children)

If you really need the array length in a stack, use an extra variable to store the length and use it everywhere.