-3
私は"may be used uninitialized in this function" for: current->next = temp;
を取得していますが、何時間も見ていますが解決策は見つかりませんでした。単一リンクリストc - この関数では初期化されていない(-Wall -Werror)
#include <stdio.h>
#include <stdlib.h>
struct node{
int data;
struct node *next;
}*head = NULL;
void add_list(int value){
struct node *temp, *current;
temp = (struct node *) malloc(sizeof(struct node));
temp->data = value;
temp->next = NULL;
if(head == NULL){
head = temp;
current = temp;
}
else{
current->next = temp;
current = temp;
}
}
int main(void){
for(int i = 0; i < 10; i++){
add_list(i);
}
return EXIT_SUCCESS;
}
:
FWIW、あなたはあなたに機能を簡素化することができますか?そしてメッセージ全体を読む。それは実際には非常に明確です。 – Olaf
私は現在の* tempの横に設定しています... if {}の中でcurren = tempを初期化する前にelse {}に決して置かれないので、 "なぜそれが非常に明確になるのですか? – TheLastStone
「何時間も見ましたが、解決策を見つけることができませんでした」 - どうしてそうするのですか?あなたのデバッガは壊れていますか? –