Learner question. I can declare and initialize a pointer in two different way
int a = 10;
int *p = &a;
also
int a = 10;
int *q;
q = &a;
I want to know what is the difference between two and how does it work in the memory?
Those two are the same :
int *p; // declaration
p = &a; // assignment
and in the other you are combining the two steps together into one:
int *p=&a; // declaration and assignment
And if you have some compiler optimizations ON, the compiler might combine the two steps.
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