void Addcostumer(){
struct CustomerData *p;
char another ='y';
char anothers ='n';
CustomerData *newcous;
char str1[80];
char str2[100];
char str3[20];
//fseek(fc,0,SEEK_END);
p=(struct CustomerData *)malloc(sizeof(struct CustomerData));
newcous= new CustomerData;
printf("Costumer Name:");
fflush(stdin);
gets_s(str1);
strcpy_s(newcous->CName,str1);
printf("Costumer Address:");
fflush(stdin);
gets_s(str2);
strcpy_s(newcous->Address,str2);
printf("Costumer Puhelin:");
fflush(stdin);
gets_s(str3);
strcpy_s(newcous->Puhelin,str3);
if ((fc = fopen("c:\\users\\Emmas4impact\\Documents\\customer.bin", "wb"))==NULL)
{
printf("Cannot open file for writing \n");
exit(1);
}
fwrite(newcous,sizeof(struct CustomerData),1,fc);
fclose(fc);
//Binary file reading
if ((fc = fopen("c:\\users\\Emmas4impact\\Documents\\customer.bin", "rb"))==NULL)
{
printf("Cannot open file for reading \n");
exit(1);
}
fread(newcous, sizeof(struct CustomerData),1, fc);
fclose(fc);
//fwrite(newcous,size,1,fc);
printf("DO YOU WANT TO SUBMIT THIS FORM (Y/N)");
fflush(stdin);
if(another=='Y'|| another=='y'){
//fwrite(newcous,sizeof(struct CustomerData),1,fc);
another=getchar();
exit(0);
}else{
//if(another=='y'||another=='Y')
another=getchar();
printf("DO YOU WANT TO ADD ANOTHER CUTOMER(Y/N)\n");
fflush(stdin);
if(anothers=='n'){
another=getchar();
newcous->Next=new CustomerData;
fwrite(newcous,sizeof(struct CustomerData),1,fc);
//break;
}else
exit(1);
}
//newcous->Next=NULL;
customer();
fclose(fc);
}
If it asked that do you want to submit this form and i type N for no it will exit so it doesn't allow me to add multiple record i don't know what's wrong with my function. Anyone with any hints?