> p2tr = &addr;<----- Is it correct? If so, what does it mean?
No, but p2tr = &ptr; would be.
Code:
int *ptr, **p2tr, addr;
ptr = &addr;
p2tr = &ptr;
// these all assign a value to addr
addr = 1;
*ptr = 1;
**p2tr = 1;
// & and * cancel out, so you can do stuff like this
*&addr = 1;
Arrays and pointers are closely linked (though not identical), and can use either notation
Code:
char c[10];
char *p;
// point to start of array
p = c;
p = &c[0];
p = c + 0;
// point to middle of array
p = &c[5];
p = c + 5;
// access an element of the array
c[0] = 'a';
*(c+0) = 'a';
p[0] = 'a';
*(p+0) = 'a';
For structures, use the -> when dealing with pointers
Code:
struct pt { int x; int y };
struct pt point;
struct pt *p = &point;
// update via pointer uses any of these
p->x = 1; // the usual way
(*p).x = 1; // the long-winded way
p[0].x = 1; // the obtuse way ;)
> Things get tricky on the pointers to functions' chapter.
Yeah, the trick to dealing with them is to use typedefs. Using them is very easy, but the declarations are something else to behold!.
Also, this site is dedicated to this singularly unique topic.
http://www.function-pointer.org/