#include #define COURSE_CODE_SIZE 6 + 1 void clearInput(void); int main(void) { int i, repetitions; int mark; char courseCode[COURSE_CODE_SIZE]; FILE *fp_out; printf ("Enter number of records: "); scanf ("%d", &repetitions); fp_out = fopen("grades.dat", "a"); for ( i = 0; i < repetitions; i++) { clearInput(); printf ("Please enter course code: "); scanf ("%[^\n]", courseCode); printf ("Please enter mark: "); scanf ("%d", &mark); fprintf(fp_out, "%s;%d\n", courseCode, mark); } fclose(fp_out); return 0; } /* End of main() program */ void clearInput(void) { while ( getchar() != '\n' ) ; } /* End of clearInput() function */