请先看如下代码:
#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 ]定义的是一维呀,可这个程序编译是正确的。应该如何理解这句宏定义?
#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 ]定义的是一维呀,可这个程序编译是正确的。应该如何理解这句宏定义?
解决方案 »
- IP地址编辑框初始化出错
- 请问如何设置CFormView初始窗口大小?
- 哪个对VC熟悉的话就添加QQ:86998008.小女子有事请教.
- 哪里有好使的 C++编译器,给小弟说一声。小弟先谢过拉 !!
- 在2000下怎么禁用和启用设备
- 如何像金山词霸一样取网页上面的词。
- 关于有没有MFC类实现数据结构里的堆栈和队列功能的模板?
- 请教: 为什么CDaoDatabase.Open() 抛出异常???
- 使用detours注入DLL和单纯使用SetWindowsHookEx建立钩子有什么区别?
- 请WIN98恢复注册表的命令在DOS 下,急谢谢
- 看看我的代码为什么会出错,谢谢了!!指针错误!!
- 一个非常奇怪的问题,还请大虾们帮助解决!
struct dictionary {
int code_value;
int parent_code;
char character;
} *dict[ TABLE_BANKS ];等于 struct dictionary dict[][TABLE_BANKS],你说1维还是二维?当然是二维的
dict[ i >> 8 ][ i & 0xff ]
就象是调指针数组,
二维没问题吧!
str[0] = "china";
str[1] = "windows";就变成了一个
char str[6][8]的2维字符数组了吧。
**dict
*dict[A]
dict[A][B]