the structure and other things have been declared already just need some help with writing this info to the file with random access method.
customer info;
void customerinfo(customer);
void customerinfo(customer info)
{
FILE *ci;
if ((ci=fopen("testing.txt","ab"))==NULL)
printf("File \"testing.txt\" could not be opened");
else
{
printf("Customer ID: ");
fflush(stdin);
scanf("%d",& info.cusid);
//fprintf(ci,"\n\nCustomer ID: %8d\n",info.cusid);
printf("Customer first name: ");
fflush(stdin);
gets(info.fname);
//fprintf(ci,"Name: %s",info.fname);
printf("Customer last name: ");
fflush(stdin);
gets(info.lname);
//fprintf(ci," %s\n",info.lname);
printf("Email: ");
fflush(stdin);
gets(info.email);
//fprintf(ci,"Email: %s\n",info.email);
printf("Phone #: ");
gets(info.phone);
//fprintf(ci,"Phone Number: %s\n",info.phone);
printf("Amount paid to date: ");
fflush(stdin);
scanf("%f",& info.apaid);
//fprintf(ci,"Amount paid to date: %.2f\n",info.apaid);
printf("Amount owed to date: ");
fflush(stdin);
scanf("%f",& info.tpaid);
//fprintf(ci,"Amount owed to date: %.2f\n",info.tpaid);
fwrite(& info,sizeof (customer),1,ci);
printf("The information has been stored");
fclose(ci);
}
}
Im trying to write all that info to the file in random access but im not sure if thats where the fwrite should be