#include<stdio.h>
#include<malloc.h>
typedef struct LNode{
char str;
struct LNode *next;
}LNode,*LinkList;
int main(){
LNode* L;
L=(LNode*)malloc(sizeof(LNode));
L->next=NULL;
LNode *s,*r=L;
char ch;
while(1){
ch=getchar();
if(ch=='\n'){
break;
}
s=(LNode*)malloc(sizeof(LNode));
s->str=ch;
r->next=s;
r=s;
}
r->next=NULL;
LNode *m=L->next;
while(m!=NULL){
printf("%c",m->str);
m=m->next;
}
return 0;
}
C语言用链表存储字符串
最新推荐文章于 2023-10-30 11:15:45 发布