/* ******************************************************* * Author: Nikitas N. Karanikolas, Assistant Professor * * Creation Date: February 21, 2009 * ******************************************************* */ #include #include "types.h" #include "commonf.c" main (int argc, char *argv[]) { overtime_rec ot1; char tmp_str[keysize]; int i, k, howmany; FILE *fp; if (argc<2) { printf("You should provide the name of the file to be created."); exit(1); } fp=fopen(argv[1],"wb"); if (fp==NULL) { printf("Can not open [%s] for writing data.", argv[1]); exit(2); } do { blank(&ot1,sizeof(overtime_rec)); printf("\nGive key: "); gets(ot1.key); printf("[%s]\n",ot1.key); strcpy(tmp_str,ot1.key); upper(tmp_str); if (strcmp(tmp_str,"QUIT")==0) break; printf("\nGive \"overtime hours\", \"saturday hours\", \"sunday hours\": "); scanf("%d %d %d", &ot1.overtime_hours, &ot1.saturday_hours, &ot1.sunday_hours); gets(tmp_str); /* garbage collection */ howmany=fwrite(&ot1,sizeof(overtime_rec),1,fp); /* printf("\nhowmany=%d\n", howmany); */ } while (1); fclose(fp); }