小编Sam*_*Paz的帖子

为什么这段代码不起作用?C++

我正在学习cpp并需要一些帮助.我的代码无效,它停止了add->value = value.

typedef struct node node;
struct node{
    int value;
    struct node *next;  
};

node *top; 

int insert(int value){
    struct node *add;
    cout<< "here it stops";
    add->value = value;
    add->next = NULL;

    if(top == NULL ){
        top == add;
    }else{
        add->next = top;
        top =  add;
    }  
}
Run Code Online (Sandbox Code Playgroud)

c++ pointers memory-management

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

标签 统计

c++ ×1

memory-management ×1

pointers ×1