Thanks for your help so far that i have achieved my goal.
My other problem is updating a particular record using fseek()
void updaterecord(void)
{
system("color 2");
struct custinfo info;
FILE *customer1;
customer1=fopen("customer1.txt","r");
if (customer1==NULL)
printf("\n\n\t\t\t FILE WAS NOT FOUND ");
else
{
char choice4;
char Target[50];
int Found=0;
if((customer1=fopen("customer1.txt","r"))==NULL)
printf("THE FILE IS EMPTY");
else
{
printf("\n\n\t\t ENTER ID NUM:");
scanf("%s",&Target);
while(!feof(customer1)&& Found==0)
{
fscanf(customer1,"%s %s %s %s %s %s %s %s",info.regis,info.Name,info.address,info.number,info.dob,info.treatment,info.allergies,info.app);
if(strcmp(Target,info.regis)==0)
Found=1;
}
if(Found)
{
printf("\n\t\t REGISTRATION:%s\n",info.regis);
printf("\n\t\t NAME:%s\n",info.Name);
printf("\n\t\t ADDRESS:%s\n",info.address);
printf("\n\t\t NUMBER:%s\n",info.number);
printf("\n\t\t DATE OF BIRTH:%s\n",info.dob);
printf("\n\t\t LAST TREATMENT:%s\n",info.treatment);
printf("\n\t\t ALLERGIES:%s\n",info.allergies);
printf("\n\t\t LAST APPOINTMENT:%s\n",info.app);
rewind(customer1);
fseek(customer1,sizeof(info),SEEK_SET);
fscanf(customer1,"%s %s %s %s %s %s %s %s",info.regis,info.Name,info.address,info.number,info.dob,info.treatment,info.allergies,info.app);
printf("\n\n\t\t\t NAME: ");
fflush(stdin);
gets(info.Name);
printf("\n\n\t\t\t ADDRESS: ");
gets(info.address);
printf("\n\n\t\t\t NUMBER: ");
gets(info.number);
printf("\n\n\t\t\t TREATMENT: ");
gets(info.treatment);
printf("\n\n\t\t\t ALLERGIES: ");
gets(info.allergies);
printf("\n\n\t\t\t DATE OF BIRTH 12/12/12: ");
gets(info.dob);
printf("\n\n\t\t\t DATE OF LAST APPOINTMENT 12/12/12: ");
gets(info.app);
fseek(customer1,sizeof(info),SEEK_SET);
fprintf(customer1,"%s %s %s %s %s %s %s %s ",info.regis,info.Name,info.address,info.number,info.dob,info.treatment,info.allergies,info.app);
printf("\n\n\t\t THE DETAILS OF THE ITEM HAS BEEN UPDATED SUCCESSFULLY");
}
else if(!Found)
printf("\n\n\t\t THERES NO SUCH RECORD");
}
}
fclose(customer1);
}