程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C >> C語言問答 >> c語言問題求糾錯

c語言問題求糾錯

編輯:C語言問答

c語言問題求糾錯

#include<stdio.h>#include<stdlib.h>struct student{ int num; char name[20]; struct student *next;}typedef struct student STU;void main(){ STU* creat(STU *top); STU *top; scanf("%d%s",&top->num,top->name ); top=creat(top); while(top->next !=NULL) { printf("%d%s\n",top->num,top->name); top=top->next; }}STU* creat(STU *top){ STU *tail; STU *p=NULL; p=top; tail=top; while (p->num!=0) { p=(STU *)malloc(sizeof(STU)); scanf("%d%s",&p->num ,p->name ); tail->next =p; tail=p; } tail->next =NULL; return top;}

搞半天不知道錯哪了。。。

最佳回答:

在 struct student *next; }後面加個分號,就是這樣struct student *next; }; 就OK了
追問:
不行。。
回答:
還會報錯?不應該呀

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved