C语言 尾插法建立单链表 插入26个英文字母0
uosnmzer2016.09.13浏览131次分享举报
#include #include #include /* run this program using the console pauser or add your own getch, system("pause") or input loop */ typedef struct LNode{ char data; struct LNode*next; }LNode,*linklist; ... #include
#include
#include
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
typedef struct LNode{
char data;
struct LNode*next;
}LNode,*linklist;
struct LNode *creat(){
struct LNode *p,*q,*head;
}
void main(){
struct LNode *p,*q,*head;
int i;
head=(linklist)malloc(sizeof(LNode));
p=head;
for(i=1;i<26;i++){
p->data=i+'a'-1;
p->next=(linklist)malloc(sizeof(LNode));
p->next;
}
p->data='z';
p->next=NULL;
}
void display(){
struct LNode *p,*q,*head;
p=head;
while(p->next!=NULL){
printf("%c",p->data);
p=p->next;
}
printf("%c\n",p->data);
}
编译没问题 为什么运行之后什么都没有? 怎么改啊? 展开