Basically i want this function to update the records in the file, but it should first prompt for the name of the employee and then retrieve the employee's details if the name matched any name in the file. Here is my attempt
void update(EMPLOYEE *details) /*EMPLOYEE refers to strusture variable i created*/
{
FILE *file;
char search;
file = fopen("employees.txt","r");
if(file == NULL)
{
printf("File error!!!");
exit(0);
}
else
{
search = getc(file);
printf("Enter name: ");
scanf("%s",details->name);
if((strcmp(search,details->name) == 0))
{
printf("%s\n",details->name);
printf("%d",details->employeeNumber);
}
}
fclose(file);
}