pointer initializatin - where to put the asterisk?
Hello there!
I am puzzled by a question lately, to wich I can't find an answer. What is the difference between the next pointer initialization methods:
Code:
int* pointer_name=NULL
and
Code:
int *pointer_name=NULL
I undestand, that the second one is the "standard" way of initializing a pointer, or at least that is how the tutorial on this website shows it, but what does the first one mean?
As I was searching the web for answers, I found another interesting example, where the pointer was initialized like this:
Code:
int * pointer_name=NULL
This was supposed to have some sort of special meaning, but I did not quite understand it, and I can't find the website now for further studying. I would be glad if someone could explain to me all these things about pointer initialization.
Big thanks in advance for everyone, reading this.
Well, here's an example...
Hm... I am trying to understand how does the next function works. It is from a SDL game programming tutorial.
Code:
SDL_Surface *load_image(char filename[])
{
SDL_Surface* loadedImage=NULL;
SDL_Surface* optimizedImage=NULL;
loadedImage=SDL_LoadBMP(filename);
if(loadedImage!=NULL)
{
optimizedImage=SDL_DisplayFormat(loadedImage);
SDL_FreeSurface(loadedImage);
}
return optimizedImage;
}
As you can see, both methods are used in this function definition - but why? Is this really just a matter of style or does it make some crucial difference if I put the asterisk to another position? As far as I tested, the program runs and compiles fine, when I play around with the asterisks, so - can it be, that the author of the tutorial wasn't consistent enough?
Thanks for the answers so far!