#include #include #include #define MAXSEATTYPES 5 #define MAXVENUES 15 #define MINVEN 2 #define MAXEVENTS 20 #define MINEVENTS 6 struct address { int stnum; char street[100]; int aptno; char city[100]; char state[2]; int zip5; char country[100]; }; struct seating { char stype; int smount; float discperc; float regperc; }; struct venue { int vcode; char venname[40]; char vtype; double venuecost; int vkindsstg; struct seating venseating[MAXSEATTYPES]; struct venue *next; }; struct event { int eday,emo,eyr; int elength; char esetting; double efixed; char ename[40]; }; int printvenbycode(struct venue *read, int tcode); int printonevenue(struct venue *read); int printven(struct venue *read); int input(struct venue venarray[15], struct event earray[20], int tv, int te); int main(void) { int done = 0; int cntr = 0; struct venue *newven=NULL, *currven = NULL, *headven = NULL, *folven=NULL; while (!done) { cntr++; newven = (struct venue *) malloc (sizeof(struct venue)); //print messages and read data into newven i.e. newven->vcode etc. currven->vcode = fabs(rand())/10000; //test data currven->next = NULL; if (headven == NULL) headven = newven; else if (headven->vcode > newven->vcode) //new element goes at front before head { newven->next = headven; headven = newven; } //new element goes between two elements in list //new element goes at end of list currven = newven; printf("\n Stuff in linked list"); printf("\nAre you done? Enter 1 for yes and 0 for no : "); scanf("%d",&done); if ((done)&&(cntrnext; } printf("\n"); } int printvenbycode(struct venue *read, int tcode) { printf("\nPrinting venue matching code %d\n",tcode); while(read != NULL) { if (tcode == read->vcode) printonevenue(read); read = read->next; } printf("\n"); return 0; } int printonevenue(struct venue *read) { printf("\n Vcode is %d",read->vcode); } int input(struct venue venarray[15], struct event earray[20], int tv, int te) { int m; struct venue temp; for (m = 0; m < tv; m++) { printf("\nVenue %d has code %d and %d kinds of seating",m+1,venarray[m].vcode, venarray[m].vkindsstg); } temp = venarray[0]; printf("\n\nVenue temp has code %d and %d kinds of seating",temp.vcode, temp.vkindsstg); return 1; }