xuwenping / spexamples

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

P19中函数sum_cb的疑问 #14

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
先静大哥,请问《系统程序员成长计划》第19页中函数sum_cb:
static DListRet sum_cb( void* ctx, void* data )
{
    long long* result = ctx;
    *result += ( int )data;

    return DLIST_RET_OK;
}

函数的第二行代码是不是应该为:*result += *( ( int* )data );

谢谢!

Original issue reported on code.google.com by jiangtao...@gmail.com on 28 Dec 2010 at 8:05

GoogleCodeExporter commented 9 years ago
不好意思,是我自己理解错了!往双链表里面存放整型数据��
�,是把整型数强制转换成void*地址来存放的,所以没有错。

Original comment by jiangtao...@gmail.com on 29 Dec 2010 at 12:42