值未分配给structPointers

问题描述

当我尝试为*temp赋值时,它没有赋值(在编译时,它不显示printf,并且按printf看不到任何赋值)。为什么呢我该如何处理有关指针的更多信息(从IDE中查看它们在外部应用程序中所引用的位置??)

    #include <stdio.h>
    #include <stdlib.h>
    #include <errno.h>
    #define INT_SIZE sizeof(int) * 8
    
    typedef struct Node Node;
    struct Node
    {
        int value;
        Node *next;
    };
    
    
    typedef struct LinkedList
    {
        Node *head;
    }LinkedList;
    
    
    void Insert(LinkedList **lst,int data)
    {
        Node *temp = malloc(sizeof(Node)); 
        //Check's if is the first Node.
        if ((*lst)->head->next== NULL)
        {       
            (*lst)->head->next = temp;  
            temp->value = data;
            printf("Ok");   
            temp->next = NULL;
        }
    }

还有我的主要功能:

int main()
{
    LinkedList *list = malloc(sizeof(LinkedList)); //Create new linkedlist
    list->head->next = NULL; //Define the head object
    Insert(&list,20);
    return 0;
}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)