Possible Duplicates:
What makes more sense - char* string or char *string?
What’s your preferred pointer declaration style, and why?
I've seen mixed versions of this in a lot of code. (This applies to C and C++, by the way.) People seem to declare pointers in one of two ways, and I have no idea which one is correct, of if it even matters.
The first way it to put the asterisk adjacent the type name, like so:
someType* somePtr;
The second way is to put the asterisk adjacent the name of the variable, like so:
someType *somePtr;
This has been driving me nuts for some time now. Is there any standard way of declaring pointers? Does it even matter how pointers are declared? I've used both declarations before, and I know that the compiler doesn't care which way it is. However, the fact that I've seen pointers declared in two different ways leads me to believe that there's a reason behind it. I'm curious if either method is more readable or logical in some way that I'm missing.
EDIT: I asked this because for the longest time, I wrote code using the method with the asterisk on the left, next to the type. (This is how I learned to declare pointers.) One day, I came upon a bit of code with multiple alike pointers, and I tried to declare them on the same line. I soon figured out that multiple pointer declarations on the same line don't work well with the way I learned to declare them, and I've been trying to figure out how to remain consistent ever since.
EDIT: My apologies for repeating a common question. I figured it must have been asked before, but it's not an easy question to search for. Thank you for your answers and clarification.