So i've recently gotten the hang of structs and am finally comfortable with Arrays, now I must tackle the files my professor wants me to be able to store 1million structs (payroll records) and im pretty sure an array that big would crash my program. So I am confused on how I can back up the structs into a txt file and upload them back into my program when started. Would the text come out as a mess? Here is the main part of my program I'll need to put into a file. It basically makes the payroll record using the struct. So i was just wondering any one could give me tips on sending this into a text file
void payRollAdd(PAYROLL employee[], long int *pCounter){
int userinput;
do{
printf("Enter Employee Name:\n");
fgets(employee[*pCounter].name, 40, stdin);
printf("Please Enter the paydate(mmddyyyy):\n");
scanf_s("%02d%02d%d", &employee[*pCounter].payDate.month, &employee[*pCounter].payDate.day, &employee[*pCounter].payDate.year);
printf("Enter Employee Age:\n");
scanf_s("%d", &employee[*pCounter].age);
printf("Enter Employee Hours Worked\n");
scanf_s("%f", &employee[*pCounter].hrsWorked);
printf("Enter Employee Hourly Wage:\n");
scanf_s("%f", &employee[*pCounter].hrlyWage);
printf(" Employee Data \n");
printf("Name: %s\n", employee[*pCounter].name);
printf("Age: %d\n", employee[*pCounter].age);
printf("Pay Date: %02d/%02d/%d:\n", employee[*pCounter].payDate.month, employee[*pCounter].payDate.day, employee[*pCounter].payDate.year);
printf("Hours Worked: %0.2f\n", employee[*pCounter].hrsWorked);
printf("Hourly Wage: $%0.2f\n", employee[*pCounter].hrlyWage);
if (employee[*pCounter].hrsWorked > 40.00){
float temp = 40.00;
employee[*pCounter].regPay = temp * employee[*pCounter].hrlyWage;
printf("Regular pay: $%0.2f\n", employee[*pCounter].regPay);
}
else
{
employee[*pCounter].regPay = employee[*pCounter].hrsWorked * employee[*pCounter].hrlyWage;
printf("Regular pay: $%0.2f\n", employee[*pCounter].regPay);
}
if (employee[*pCounter].hrsWorked > 40.00){
float temp2 = 0.00;
temp2 = employee[*pCounter].hrsWorked;
temp2 -= 40.00;
employee[*pCounter].otPay = temp2 * `(employee[*pCounter].hrlyWage + (employee[*pCounter].hrlyWage / 2.00));`
printf("OT pay: $%0.2f\n", employee[*pCounter].otPay);
}
else
{
employee[*pCounter].otPay = 0;
printf("OT pay: $0\n");
}
employee[*pCounter].totalPay = employee[*pCounter].regPay + employee[*pCounter].otPay;
printf("Total Pay: $%0.2f\n", employee[*pCounter].totalPay);