I have one question
if I have *X[2]
(*X)[2]
what do those mean?
Also, what would a poosible decleration of X be?
Thanks a lot, Im new to C, and am not familiar with pointers
I have one question
if I have *X[2]
(*X)[2]
what do those mean?
Also, what would a poosible decleration of X be?
Thanks a lot, Im new to C, and am not familiar with pointers
The first gives you the value contained in the array, the second dereferences the pointer first and as an end result you get the address of the second pointer rather than its contents.Code:#include <stdio.h> int main(void) { int a,b,c,*x[3] = { &a, &b, &c }; a = 10; b = 20; c = 30; return printf( "%d vs %d\n", *x[2], (*x)[2] ); }
Quzah.
Hope is the first step on the road to disappointment.
And also read thisCode:#include <stdio.h> int main ( void ) { int a = 1, b = 2, c = 3; // 3 ints int d[3] = { 10, 11, 12 }; // an array of 3 ints int *x[3] = { &a, &b, &c }; // 3 pointers to 3 ints int (*y)[3] = &d; // one pointer to an array of 3 ints printf( "%d %d %d\n", a, b, c ); printf( "%d %d %d\n", d[0], d[1], d[2] ); printf( "%d %d %d\n", *x[0], *x[1], *x[2] ); printf( "%d %d %d\n", (*y)[0], (*y)[1], (*y)[2] ); return 0; }
http://pw2.netcom.com/~tjensen/ptr/cpoint.htm