随笔-C-指针数组使用简记
64位
typedef struct mem_list* cns_detail_encode_result[encode_type_max];
(gdb) p &(( struct mem_list**)0x7fffb4557950)[0] # & 取对应点的位置
$29 = ( struct mem_list **) 0x7fffb4557950
(gdb) p (( struct mem_list**)0x7fffb4557950) + 0
$30 = ( struct mem_list **) 0x7fffb4557950
(gdb)
(gdb)
(gdb) p &(( struct mem_list**)0x7fffb4557950)[1]
$31 = ( struct mem_list **) 0x7fffb4557958
(gdb) p (( struct mem_list**)0x7fffb4557950) + 1
$32 = ( struct mem_list **) 0x7fffb4557958
(gdb)
(gdb)
(gdb) p (( struct mem_list**)0x7fffb4557950)[1] # 没有& 取对应地址的值
$33 = ( struct mem_list *) 0x0
void test(struct epoll_event *events, int count)
{
struct epoll_event *item;
int i;
for (i = 0; i < count; i++) {
item = &events[i];
...
}
}
int main(int argc, void *argv[])
{
struct epoll_event events[4] = { 0 };
...
test(events, 4);
...
}
本文来自博客园,作者:LiYanbin,转载请注明原文链接:https://www.cnblogs.com/stellar-liyanbin/p/17624513.html