Dev正常运行 VS报错 求解答

#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却显示如上的错误 求解答

pold没有绝对赋值的地方。如果先执行else处理,那么第43行使用pold->next就会崩溃。编译器是这么想的,所以你要初始化pold