
谁能帮我详细解释下这段程序的意思,c语言的,在线等
从p=(pointer*)malloc(sizeof(structpointer));开始#include<stdio.h>#include<stdlib.h>typed...
从p=(pointer *)malloc(sizeof(struct pointer));开始
#include<stdio.h>
#include<stdlib.h>
typedef struct pointer{
char dat;
struct pointer *link;
} pointer;
void readdata(pointer *head){ //读集合
pointer *p;
char tmp;
printf("input data ('0' for end):");
scanf("%c",&tmp);
while(tmp!='0')
{
if((tmp<'a')||(tmp>'z'))
{
printf("\n");
return;
}
p=(pointer *)malloc(sizeof(struct pointer));
p->dat=tmp;
p->link=head->link;
head->link=p;
scanf("%c",&tmp);
}
} 展开
#include<stdio.h>
#include<stdlib.h>
typedef struct pointer{
char dat;
struct pointer *link;
} pointer;
void readdata(pointer *head){ //读集合
pointer *p;
char tmp;
printf("input data ('0' for end):");
scanf("%c",&tmp);
while(tmp!='0')
{
if((tmp<'a')||(tmp>'z'))
{
printf("\n");
return;
}
p=(pointer *)malloc(sizeof(struct pointer));
p->dat=tmp;
p->link=head->link;
head->link=p;
scanf("%c",&tmp);
}
} 展开
展开全部
p=(pointer *)malloc(sizeof(struct pointer));//为指针p申请内存空间
p->dat=tmp;//这个不用解释了吧
p->link=head->link;//下面两行把p插入到链表的头部
head->link=p;//
p->dat=tmp;//这个不用解释了吧
p->link=head->link;//下面两行把p插入到链表的头部
head->link=p;//
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询