You are on page 1of 1

// Ask for input for each employee

printf("Please enter information for %d employees:\n",


MAX_EMPLOYEES);
for (int i = 0; i < MAX_EMPLOYEES; i++) {
printf("Employee %d:\n", i+1);
printf("Name: ");
scanf("%s", employees[i].name);
printf("Address: ");
scanf("%s", employees[i].address);
printf("Age: ");
scanf("%d", &employees[i].age);
printf("\n");
}

// Write employee data to file


FILE *fp = fopen("EMPLOYEE.DOC", "w");
if (fp == NULL) {
printf("Error: could not open file\n");
return 1;
}

You might also like