请先看如下代码:
#define BITS                       15
#define MAX_CODE                   ( ( 1 << BITS ) - 1 )
#define TABLE_SIZE                 35023L
#define TABLE_BANKS                ( ( TABLE_SIZE >> 8 ) + 1 )
#define END_OF_STREAM              256
#define BUMP_CODE                  257
#define FLUSH_CODE                 258
#define FIRST_CODE                 259
#define UNUSED                     -1struct dictionary {
    int code_value;
    int parent_code;
    char character;
} *dict[ TABLE_BANKS ];#define DICT( i ) dict[ i >> 8 ][ i & 0xff ]这是我在LZW算法中看到的代码片段,让我不能理解的是“#define DICT( i ) dict[ i >> 8 ][ i & 0xff ]”这一句,宏定义DICT(i)等价于dict[ i >> 8 ][ i & 0xff ],是个二维下标,但*dict[TABLE_BANKS ]定义的是一维呀,可这个程序编译是正确的。应该如何理解这句宏定义?

解决方案 »

  1.   

    嘿嘿。这分也赚了吧。反正闲着也是闲着
    struct dictionary {
        int code_value;
        int parent_code;
        char character;
    } *dict[ TABLE_BANKS ];等于 struct dictionary dict[][TABLE_BANKS],你说1维还是二维?当然是二维的
      

  2.   

    *dict[ TABLE_BANKS ] 是个指向指针的数组,可以用二维下标表示。比如 char* str[2], 你可以用str[0][0] 表示第一个字符。
      

  3.   

    我觉得*dict[ TABLE_BANKS ];本身就是个结构指针,
    dict[ i >> 8 ][ i & 0xff ]
    就象是调指针数组,
    二维没问题吧!
      

  4.   

    比方说这样吧char* str[2];
    str[0] = "china";
    str[1] = "windows";就变成了一个
    char str[6][8]的2维字符数组了吧。
      

  5.   

    二维数组有以下表示方法
    **dict
    *dict[A]
    dict[A][B]