This sounds quite noob. But when you declare a pointer, does it matter where the unary operator (*) is placed. Such as in,orCode:int* p;
Or is this just a preference thing?Code:int *p;
Printable View
This sounds quite noob. But when you declare a pointer, does it matter where the unary operator (*) is placed. Such as in,orCode:int* p;
Or is this just a preference thing?Code:int *p;
Preference.
As for myself I usually put the asterisk near the type for single variables and function heads,
and the asterisk closer to the identifier when I declare many variables in one statement,Code:int* p;
void func (int* p);
Code:int *p, i;
SDL_Surface *window, *font, *background;
It doesn't really matter, but just remember that it doesn't distribute across many variables. For example:
Only p is a pointer. You would need to do it like so:Code:int* p, a, b, c;
Code:int* p, *a, *b, *c;
Ah, I see what you mean there about it not distributing across the variables. I prefer the asterisk closer to the variable name, rather the data type. BTW you posted at the same time :p