高手来帮忙,c语句 隐性赋值,我的程序在哪里值发生了改变?

来源:百度知道 编辑:UC知道 时间:2024/09/25 02:31:52
本人编了个建立链表的程序,程序如下:
#include "Stdio.h"
#include "Conio.h"
#include "string.h"

typedef struct student
{int data;
struct student *next;
}node;

node *creat()
{
node *head,*p,*s;
int x, cycle=1;
head=(node*)malloc(sizeof(node));
p=head;
printf("\n%d %d %d %d",head,p,head->next,p->next);
while(cycle)

{
printf("\nplease input the data:");
scanf("%d",&x);
if(x!=0)
{
s=(node*)malloc(sizeof(node));
s->data=x;
printf(" %d",s->data);
printf("\n %d",head->next);
p->next=s;
printf("\n%d %d",head->next,s );
p=s;
}
else cycle=0;
}
printf("\n%

给链表结点开辟空间这一点有时真让人搞不明百。
待我下去问问老师。

请注意,P=HEAD
HEAD=HEAD NEXT
P=P NEXT

有难度,等我看看

头痛
不看了