如何使用带有双指针变量(没有支持变量)的结构字段?

问题描述 投票:2回答:2

我在c中有此结构

struct node{
    int info;
    struct node* link;
};

此过程:

void example(struct node** head){
    struct node* tmp;
    tmp=*head;
    tmp->info=0;
    *head=tmp;
}

并使用]调用主过程>

example(&head); 

所以要修改head-> info,我需要一个支持变量,还有没有支持变量的另一种方法吗?

我在c struct node {int info;中有这个结构; struct node *链接; };这个过程:void example(struct node ** head){struct node * tmp; tmp = * head; tmp-> info = 0; * head = tmp; ...

c list pointers struct parameter-passing
2个回答
1
投票

使用此:


1
投票

如果您有一个指向像这样声明的对象的指针>

struct node *head; 
head = malloc( sizeof( struct head ) );
© www.soinside.com 2019 - 2024. All rights reserved.