0

I'm learning C and I'm wondering about the difference between writing type* variable and type *variable.

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Laura
  • 13
  • 2
  • It's a matter of preference, but as the accepted answer says, in `int* myVariable, myVariable2;` it may not be *immediately* obvious that `myVariable2` is `int` and not `int *`. – Weather Vane May 30 '21 at 17:08
  • For the same reason we *don't* declare arrays as `type[N] variable;` - the `*` is part of the *declarator*, not the type specifier. Because whitespace is not significant (at least in this case) you can write it either way, but it is always *parsed* as `type (*variable);`. – John Bode May 30 '21 at 17:57

0 Answers0