HaveF / spexamples

Automatically exported from code.google.com/p/spexamples
0 stars 0 forks source link

p56页的比较函数? #16

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
int int_cmp(void *a, void *b) {
    return (int)a - (int)b; 
}
这样比较不是指针地址吗?可以这样做吗?还是一处错误?

谢谢

Original issue reported on code.google.com by joshua...@gmail.com on 18 Aug 2011 at 8:13

GoogleCodeExporter commented 9 years ago
同一页的 typedef int (*DataCompareFunc) (void *ctx, void *data);
这个ctx是什么意思,也是上下文吗,还是比较数之一呢?

Original comment by joshua...@gmail.com on 18 Aug 2011 at 8:16

GoogleCodeExporter commented 9 years ago
我明白了,INT 大小和VOID*一样。。所以可以互转

Original comment by joshua...@gmail.com on 23 Aug 2011 at 6:07

GoogleCodeExporter commented 9 years ago
据作者说,可以是任何类型,实际上只有int才可以,无从理��
�,到底什么意思,也没个代码示例,巨坑,还turing。。。

Original comment by deng...@gmail.com on 19 Apr 2014 at 1:44