C語言連結串列邏輯問題

2022-09-05 04:55:16 字數 396 閱讀 4271

1樓:匿名使用者

tail->next = null;本身沒有錯錯的是你的print()函式裡的while表示式while( box->next != null ) 應該改為 while( box != null );

只有box不為null,才能繼續遍歷,才有box->next;

2樓:匿名使用者

chuangjian()函式沒什麼大問題

問題主要在print()函式裡

void print(struct stu * box)}

3樓:匿名使用者

邏輯上看沒有問題,但是下面這一行:

scanf("%s", &niu->name);

存在陣列越界的情況。

C語言連結串列

struct lnod create int a q next null return head 由於上面的原因,返回值是null!int data head q struct lnod malloc sizeof lnod scanf d data while data 3 這種方法的head節點...

C 雙向連結串列問題,C 模板雙向連結串列問題

3全部 include using namespace std template class doublelist node prev null next null int thesize node head node tail public doublelist doublelist thesiz...

c語言單連結串列問題這個程式執行有問題

主要是scanf的問題,這個函式作為輸入並不太好用。scanf d i 這裡輸入之後,讀取了i的值,但是從鍵盤輸入的回車鍵沒處理,還在緩衝區中,下次再呼叫gets函式的時候就讀取了緩衝區的回車符,所以第二次gets name 獲取的就是一個空字串,然後程式就結束了。解決辦法就是在scanf語句後面加...