/* ******************************************************* * Author: Nikitas N. Karanikolas, Assistant Professor * * Creation Date: February 20, 2009 * ******************************************************* */ #include typedef struct { char name[40]; char island[20]; int single_bed; int double_bed; int twin_bed; int gt_double; /* greater than double room */ char facilities[100]; } hotel_rec; char *islands[]={"Patmos", "Arki", "Lipsi", "Leros", "Kalymnos", "Pserimos", "Kos", "Astypalaia", "Nisyros", "Symi", "Tilos", "Chalki", "Rhodes", "Kastelorizo", "Karpathos", "Kasos"}; void upper(char *str) { int i; for (i=0; i= 97) && (str[i] <= 122)) str[i] = str[i] - 32; } void blank(char buffer[], int size) { int i; for (i=0; isizeof(islands)/sizeof(char *))); printf("[%s]\n",islands[k-1]); strcpy(h1.island,islands[k-1]); gets(tmp_str); /* garbage collection */ printf("\nGive number of single, double, twin-bed and " "greater-than-double rooms: "); scanf("%d %d %d %d", &h1.single_bed, &h1.double_bed, &h1.twin_bed, &h1.gt_double); printf("[%d] [%d] [%d] [%d]\n", h1.single_bed, h1.double_bed, h1.twin_bed, h1.gt_double); gets(tmp_str); /* garbage collection */ printf("\nDescribe facilities: "); gets(h1.facilities); printf("[%s]\n",h1.facilities); howmany=fwrite(&h1,sizeof(hotel_rec),1,fp); /* printf("\nhowmany=%d\n", howmany); */ } while (1); fclose(fp); }