#include<stdio.h>
#include<stdlib.h>
struct student
{
int num;
float score;
struct student* next;
};
void print(struct student* head)
{
while (head != NULL)
{
printf("num:%d,score:%.2f\n", head->num, head->score);
head = head->next;
}
}
struct student* create()
{
struct student* head = NULL;
struct student* pnew, * pold;
int num;
float score;
scanf_s("%d %f", &num, &score);
if (num == 0 && score == 0)
{
printf("Empty!\n");
return head;
}
do
{
pnew = (struct student*)malloc(sizeof(struct student));
pnew->num = num;
pnew->score = score;
if (head == NULL)
{
head = pnew;
pnew->next = NULL;
pold = head;
}
else
{
pnew->next = pold->next;
pold->next = pnew;
pold = pnew;
}
scanf_s("%d %f", &num, &score);
} while (num != 0 && score != 0);
printf("Scores are:\n");
return head;
}
int main()
{
struct student* head;
head = create();
print(head);
return 0;
}
同样的代码在Dev可以正常运行 在VS却显示如上的错误 求解答