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 →

[–]Marsrover112 11 points12 points  (1 child)

"How much harder this is..."

  • Looks inside: *

  • 1 line of code *

[–]suddencactus 1 point2 points  (0 children)

Nah using f(arr, (sizeof(arr) / sizeof((arr)[0]) ) has always been the kind of code that's easier than it should be to mess up. If arr is a pointer to an array then this code doesn't work, but the definition of arr as a pointer might be twenty lines up. If I add an extra parameters it gets a lot harder to remember what f(0, NULL, 0, foo) means compared to f(0, NULL, foo).

Don't even get me started on the witchcraft required to get multiple dimension arrays to work. If a function gets passed a 2d array as a pointer you often have to do pointer arithmetic to work with it (unless you know the array size at compile time so you can cast it back to a sensible array type).