小编pra*_*eep的帖子

取消引用指针

当我在fill函数中打包结构并传递指针以发送如何取消引用它时,如何取消引用指针?因为我在我所做的事情中得到了分段错误

#include<stdio.h>
struct xxx
{
    int x;
    int y;
};

void fill(struct xxx *create)
{
    create->x = 10;
    create->y = 20;
    send(*create);
}


main()
{
    struct xxx create;
    fill(&create);
}

send(struct xxx *ptr)
{
    printf("%d\n",ptr->x);
    printf("%d\n", ptr->y);
}
Run Code Online (Sandbox Code Playgroud)

c pointers

3
推荐指数
1
解决办法
519
查看次数

标签 统计

c ×1

pointers ×1