// ConsoleApplication1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
#define TSIZE 50
#define FMAX 2
struct film
{
char title[TSIZE];
int ranting;
struct film * next;
}* head,* prev,*current;
struct film * NewArrayList();
struct film * AddList(struct film *current,char*,char*);
struct film * getList();
struct film * NewArrayList(){
head=NULL;
return head;
}
struct film * AddList(struct film *current,char *c1,int c2){
current=(struct film *)malloc(sizeof(film));
if(head==NULL)
head=current;
else{
prev->next=current;
}
current->next=NULL;
prev=current;
strcpy_s(current->title,c1);
memcpy(¤t->ranting,&c2,sizeof(c2));
return current;
}
struct film * getList(){
return head;
}
int _tmain(int argc, _TCHAR* argv[])
{
struct film * list=NewArrayList();
AddList(list,"a",1);
AddList(list,"b",2);
current=getList();
while (current!=NULL)
{
struct film * li=current->next;
printf("数据为:标题%s,数量为:%d \n",current->title,current->ranting);
free(current);
current=li;
}
return 0;
}