Between formal parameters in a function definition, like:
void change (int *s)
{
s[0] = 42;
}
And another definition:
void change (int s[])
{
s[0] = 42;
}
They are the same I assume, as *(a+0) is the same as a[0].
Is there a reason to prefer one over the another? Please note, the preference pertains to coding style.
Yes, they are exactly the same. All function parameters declared as arrays are adjusted to the corresponding pointer type.
Personally, I prefer the former which actually makes it look like a pointer declaration which is what it is in both cases.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With