Think of pointers as variables that contain memory addresses. tname contains a memory address of a variable that contains the address of a character. Pointer to a pointer variables are often synonymous with arrays, and char ** many times indicates a pointer to an array of character strings (which are null terminated char arrays).
Dereferencing a pointer variable means you access the contents at the memory address in the pointer variable.
Clear as mud now? # Pointers are usually considered the most difficult thing to learn in C/C++.
I know I didn't really get a handle on them until I had a dream one night about programming using them. I woke up from the dream while it was still dark out and wrote down what I'd dreamed of programming by the light of the moon. In the morning I tried the code and it compiled and worked perfectly, and since then have had little trouble with them. # I'm not sure how others have gotten the concept down, though.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.