2016.09.28 film.c

#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>//为exit()提供原型
#include"list.h"//定义List Item
void showmovies(Item item);

int main()
{
    List movies;
    Item temp;

    InitializeList(&movies);
    if (ListIsFull(movies))
    {
        fprintf(stderr, "No memory available!Bye!\n");
        exit(1);
    }
    puts("Enter first movie title:");
    while (gets(temp.title) != NULL && temp.title[0] != '\0')
    {
        puts("Enter your rating <0-10>:");
        while (scanf("%d", &temp.rating) != 1 || temp.rating < 1 || temp.rating > 10)
            puts("Enter again!");
        while (getchar() != '\n')
            continue;
        if (AddItem(temp, &movies) == false);
        {
            fprintf(stderr, "Problem allcoating memory\n");
            break;
        }
        if (ListIsFull(movies))
        {
            puts("The list is now full.");
            break;
        }
        puts("Enter next movie title (emptyline to stop):");
    }
        if (ListIsEmpty(movies))
            printf("No data entered.");
        else
        {
            printf("Here is the movies list:\n");
            Traverse(movies, showmovies);
        }
        EmptyTheList(&movies);
        printf("Bye!\n");
        return 0;
}
void showmovies(Item item)
{
    printf("MovieL %s\t Rating: %d\n", item.title, item.rating);
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值