I know, i should have got the hang of this a long long time ago
anyway, i have come up with these three pointer rules:
"*ptr" to retrive the data pointed too or to declare a pointer.
"&ptr" to retrive the memory address of a pointer.
"ptr" to retrieve the memory address pointed too by a pointer.
Now i just want to be sure that i'm not missing anything or am making the wrong assumptions.
Pointer confusion
Pointer confusion
This was supposed to be a cool signature...
Of course, but if thats the only thing, i think im finaly on my way. The think is i dont use pointers very much and tend to forget exactly how they work.AlexExtreme wrote:When you say "to declare a pointer", it needs to be preceded by a type, like char *ptr. Just *ptr wouldn't work to declare a pointer
This was supposed to be a cool signature...
It does take a bit of work to get the hang of using them in C/C++, doesn't it?
I still remember the days where I would just randomly insert &s and *s until my code compiled. You might well imagine that I never coded with pointers then, but when I copied code from others sometimes a pointer would turn up...
When you start using pointers a good bit and get the hang of them though, you'll be glad you understand how to use them.
I still remember the days where I would just randomly insert &s and *s until my code compiled. You might well imagine that I never coded with pointers then, but when I copied code from others sometimes a pointer would turn up...
When you start using pointers a good bit and get the hang of them though, you'll be glad you understand how to use them.