C語言結構體問題

時間 2022-04-09 19:55:10

1樓:匿名使用者

#include

#include

struct student ;

struct student *add(struct student *head)

struct student *del(struct student *head,long number)

while (number!=p1->number&&p1->next!=null)

if (number==p1->number)

return(head);

}struct student *find(struct student *head,long number)

p1=head;

while (number!=p1->number&&p1->next!=null)

p1=p1->next;

if (number==p1->number)

return(p1);

else return(null);

}int main()

2樓:寒寒家

1.為什麼要把函式的宣告,結構體的定義都放到main函式中呢。像樓上的那種風格多好,這個可能是編譯不通過的原因。

2.add函式不對,

while(p2!=null)

p2=p2->next;

這個迴圈之後p2=null

但是你後面還有p2->next;

可以先判斷p2是否為null

然後while(p2->next!=null)

c語言結構體別名定義問題,C語言結構體別名定義問題

typedef struct stu linklist 此處第一了一個型的型別,即struct stu 即指向結構體stu的指標 所以head的型別也就是struct stu head為一個指向stu結構體型別的指標。但是並沒有未其分配具體的空間。可以將一個已定義為stu結構體的指標賦給它。 c語言...

C語言結構體定義,C語言結構體定義 25

chanrich輕輕 所謂結構體陣列,是指陣列中的每個元素都是一個結構體。在實際應用中,c語言結構體陣列常被用來表示一個擁有相同資料結構的群體,比如一個班的學生 一個車間的職工等。結構體可以儲存不同的資料型別,將他們互相聯絡起來。結構體陣列可以連續儲存多個結構體,和陣列作用相似。比如想定義同一個最小...

C語言連結串列與結構體,c語言結構體與連結串列

北風微風 include include define null 0 define len sizeof struct student struct student int n struct student creat void if n 0 head null p2 next null free ...