#include <stdio.h> #include <malloc.h> #define OK 1 #define ERROR 0 typedef int status; typedef struct Subject { float score; char course; struct Subject *next; }Subject,*SList; status create_S(SList &L) { SList p; int i,n; L=(Subject *)malloc(sizeof(Subject)); L->next=NULL; printf("Input the element number:"); scanf("%d",&n); printf("Input the element value reversing:\n"); for (i=n;i>0;--i) { p=(Subject *)malloc(sizeof(Subject)); scanf("%s,%f",&p->course,&p->score); p->next=L->next; L->next=p; } printf("The linklist as follow:\n"); for (i=0;i<n;++i) { printf("%s,%f\n",&p->course,&p->score); p=p->next; } printf("\n"); return OK; } void main(){ SList head; create_S(head); }
结果是这样,请问哪里出错了?
要怎么改?
相关分类