Remix.run Logo
uecker 2 days ago

In practice, the [static n] notation can give you useful warnings and bounds checking.

https://godbolt.org/z/PzcjW4zKK

And while the (*array_ptr)[3] notation take a moment to get used to, it is very logical. If you have a pointer to an array, you dereference it first and then indx into it. Again, useful for bounds checking: https://godbolt.org/z/ao1so9KP7

keyle an hour ago | parent | next [-]

I know of this notations but I don't see many people using [static n].

Not sure why, maybe it doesn't feel like C anymore, maybe it feels hacky?

typically if you're passed an array you'd want to get more anyway, so you'd get passed a struct. Not sure.

dnautics 2 hours ago | parent | prev [-]

What is **int[3][5]

thrance an hour ago | parent | next [-]

A pointer to a pointer to a pointer to a pointer of integers.

ori_b 2 hours ago | parent | prev [-]

A syntax error. You need a variable name, not a type name, in the middle.

fusslo an hour ago | parent | next [-]

or a rejected PR

ori_b 2 hours ago | parent | prev [-]

And if you want 'int **arr[a][b]', it's a value that when you say 'x = **arr[m][n]', will evaluate to an int and assign it to x. Postfix has higher precedence than prefix.