I have a file that contains information on employees in the following format:
Name: Belal Kassem
Service: Security
Date of Birth: 1995
Salary: 500Name: Abdallah Yasser
Service: Marketing
Date of Birth: 1954
Salary: 500Name: Hend Elkarmouty
Service: Dentist
Date of Birth: 1990
Salary: 800
I would like my program to search for an employee's name, which is indicated by the user, and then return true
or false
(found/not-found).
However, right now, my program only asks for the number of employees I want to remove and their names.
int NumToDelete;
printf("How much employees do you want to remove?\n");
scanf(" %d", &NumToDelete);
fgetc(stdin);
char Name[NumToDelete][25];
for(int i = 0; i < NumToDelete; i++)
{
printf("Name: ");
fgets(Name[i], 25, stdin);
char BarLoc, NameFinder[25];
int line = 0;
FILE *fremove = fopen("Employees.txt", "r");
do
{
if((line % 5) == 0)
{
fseek(fremove, 6, SEEK_CUR);
fgets(NameFinder, 25, fremove);
if(NameFinder == Name[i])
{ //This is not the official code.
printf("%s", NameFinder); //Just to check if it is working or not.
} //Here it is suppose to be the deleting code.
}
BarLoc = getc(fremove);
if(BarLoc == '\n')
{
line++;
}
}while(BarLoc != EOF);
I would also like to print out, using the NameFinder variable, all employees which were deleted.