2011年11月8日 星期二

VC: pointer to pointer

Reference1: http://c-faq.com/~scs/cclass/int/sx8.html
Reference2: http://blog.xuite.net/coke750101/coketech/20670525

Example:    char **pa;    可以重寫為   char *(*pa);
   若 pa = 0x1000; 
  *(pa+0) : 0x1000  ----> [0x009a]
  *(pa+1) : 0x1002  ----> [0x009f ]
  *(pa+2) : 0x1004  ----> [0x00a3]

   //address      value
    [0x009a] =  B
    [0x009b] = O
    [0x009c] = O   <-----*(*pa)+2
    [0x009d] = K
    [0x009e] = '0'

    [0x009f] = Y
    [0x00a0] = O  <-- *(*pa+1)+1
    [0x00a1] = U
    [0x00a2] = '0'

    [0x00a3] = T 
    [0x00a4] = E
    [0x00a5] = S
    [0x00a6] = T   <--- *(*pa+2)+3
    [0x00a7] = '0'
 
    [0x1000] = 0x009a   <-- *pa  
    [0x1002] = 0x009f   <-- *(pa+1)
    [0x1004] = 0x00a3  <-- *(pa+2)
   
    [0x????] = 0x1000   <-- pa