69,371
社区成员
发帖
与我相关
我的任务
分享
printf("now,top item's name:%s\n",pitem->name);
puts("hello,world.");
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "data_struct.h"
int main(void)
{
struct Stack my_stack;
InitStack(&my_stack);
int i=3;
while(i--){
struct Item item;
printf("Enter moive's name :\n");
scanf("%s",item.name);
printf("Enter moive's rating :\n");
scanf("%d",&item.rating);
PushStack(&my_stack,item);
}
printf("now ,stack has %d item.\n",NumOfItemInStack(&my_stack));
i=2;
while(i--){
struct Item item;
PopStack(&my_stack,&item);
printf("pop item's name:%s\n",item.name);
printf("pop item's rating:%d\n",item.rating);
}
printf("now ,stack has %d item.\n",NumOfItemInStack(&my_stack));
struct Item *pitem=TopStack(&my_stack);
if(pitem==NULL){
puts("wrong");
}
printf("now,top item's name:%s\n",pitem->name);
puts("hello,world.");
return 0;
}