2008年7月16日 星期三

struct, array, pointer

ex:
struct people{
        int age;
        int height;
};

struct people a[10];
&a: bffff988  a:bffff988  &a[0]: bffff988  &a[1]:bffff990  (a+1):bffff990
because the size of struct people is 8,  (a+1)= &a[1]- &a[0]= bffff988+ 8= bffff990

struct people *b=a;
b+1 equals a+1
b[1] equals a[1]

沒有留言: