Hi Everyone
Hope you are all well.
I've been tasked with an assignment at collage to create an employee management system, so far i've done well and managed to create a working program which i am happy with :) However there is an optional function that can be created that will sort records based on the desired field. I've been doing well up until now, i just can figure out the correct/best way to compare the information for sorting.
I understand techniques that can be used, for example setting up two counter controlled loops to go through arrays making comparisons. i'm just not sure how to implement this when reading structures from a text file.
my structure looks like this
struct Employee_Data {
int Employee_Number;
char Title[10];
char First_Name[30];
char Surname_Name[30];
char Middle_Name[30];
char DOB[10];
char Gender[1];
float Salary;
};
and i read the data from the saved file using
void Read_Info(void)
{
system("cls");
FILE *EMS;
struct Employee_Data Input;
EMS = fopen("HREMS.dat","r");
if(!EMS)
{
puts("No data");
Pause();
return;
}
while(fread(&Input,sizeof(Input),1,EMS))
{
//Display data
}
Pause();
fclose(EMS);
}
Should i create an Array of structures and copy the Information using the void Read_Info(void) function into each struct?
Any help will be greatly appreciated.
Many Thanks