如图,想问问为什么不能输出
#include
#include
#include
typedef struct list{
char elem;
struct list* next;
}List;
void Input(List* L,int n)
{
int i;
for(i=0;imalloc(sizeof(List));
printf("输入字符,按下回车读取:");
scanf("%c",&(L->elem));
getchar();
L=L->next;
}
}
void showList(List* L,int n)
{
int i;
for(i=0;iif(L->next==NULL)
{
fprintf(stderr,"error");
exit(1);
}
printf("第%d 个字符%c\n",i,L->elem);
L=L->next;
}
}
int main()
{
List LI;
Input(&LI,7);
printf("%c",LI.elem);
showList(&LI,7);
return 0;
}
例如输入a
a
a
a
不能输出