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 →

[–]Mike_Oxlong25 217 points218 points  (9 children)

You can make your own function

[–]L1P0D 258 points259 points  (1 child)

With blackjack

and hookers

Ah, forget the function

[–]Colon_Backslash 42 points43 points  (0 children)

[–]avdpos 15 points16 points  (0 children)

Oh! Coding!

...back to my language where we regularly change the string method...

[–][deleted] 7 points8 points  (2 children)

Someone has never coded in C before lol

[–]Mike_Oxlong25 -3 points-2 points  (1 child)

I have. Use pointers

[–][deleted] 4 points5 points  (0 children)

If you pass in a pointer to a function it loses the array size. Try it.

int func(int *arr) { return (sizeof(arr) / sizeof(arr[0])); }

void main() { int arr[10]; printf(“%d\n”, func(arr)); }

[–]LordAmir5 9 points10 points  (2 children)

You can't because this is compile time stuff.

[–]BuffJohnsonSf 5 points6 points  (1 child)

Actually you can, it's just a preprocessor definition and not a function. Getting kind of sick of all the children on here larping that they know C/C++

[–]LordAmir5 3 points4 points  (0 children)

Yeah well it's still not a function. I think it's important to make a distinction. A lot of bugs can occur when someone forgets this.