#include #define NAME_SIZE 80 + 1 #define TITLE_SIZE 40 + 1 void clearInput(void); main() { int age; char employeeName[NAME_SIZE]; char employeeTitle[TITLE_SIZE]; char again; FILE *fpout; fpout = fopen("employee.dat", "a"); do { printf ("Enter Name: "); scanf ("%[^\n]", employeeName); clearInput(); printf ("Enter age: "); scanf ("%d", &age); clearInput(); printf ("Enter job title: "); scanf ("%[^\n]", employeeTitle); clearInput(); fprintf (fpout, "%s,%d,%s\n", employeeName, age, employeeTitle); printf ("Go again? [y/n]: "); scanf (" %c", &again); clearInput(); }while ( toupper(again) == 'Y'); fclose(fpout); } /* end of main program */ void clearInput(void) { while(getchar() != '\n') ; } /* end of clearInput() function */