字符类型输入???
/*从键盘输入字符串后逆向输出*/#include "malloc.h"
typedef struct stack
{
int data;
struct stack *next;
}Linked_Stack;
Linked_Stack *Ls_top=NULL;
void Ls_push(char i)
{
Linked_Stack *ptr;
ptr=(Linked_Stack *) malloc (sizeof(Linked_Stack));
ptr->data=i;
ptr->next=Ls_top;
Ls_top=ptr;
}
void Ls_pop()
{
Linked_Stack *ptr;
if(Ls_top==NULL)
printf("栈表为空!\n");
else
{
ptr=Ls_top;
Ls_top=ptr->next;
printf("%c",ptr->data);
}
}
红字那段代码明明定义了字符类型 ,为什么可以接收字符串?????????
void Ls_Rr()
{
char i;
scanf("%c",&i);
while(i!='\n')
{
s_push(i);
scanf("%c",&i);
}
while(Ls_top!=NULL)
{
Ls_pop();
}
}
main()
{
Ls_Rr();
}