why my program don't execute?
void Supplier::AddDetails()
{
char ch='y';
int end;
fstream suppauto;
suppauto.open("Supplier.txt",ios::app);
suppauto.seekg(0,ios::end);
while (ch=='y')
{
char s[12];
system("cls");
cout<< " Adding Supplier Details"<<endl;
cout<<" ****************************************"<<endl<<endl;
suppauto.seekg(0,ios::end);
end=suppauto.tellg();
if (end==0)
{
suppauto.close();
strcpy(suppcode,"S0001");
}
else
{
suppauto.close();
for(int i=0;i<6;i++)
suppcode[i] = '\0';
fstream suppauto1("Supplier.txt",ios::in);
while(!suppauto1.eof())
{
suppauto1.read( (char *)this, sizeof(class Supplier) );
}
suppauto1.close();
int supcode;
char supp[6];
supp[0]=suppcode[1];
supp[1]=suppcode[2];
supp[2]=suppcode[3];
supp[3]=suppcode[4];
supp[4]='\0';
supcode=atoi(supp);
supcode++;
if (supcode<=9)
{
strcpy(suppcode,"S000");
strcat(suppcode,itoa(supcode,s,20));
}
if (supcode>9 && supcode<=99)
{
strcpy(suppcode,"S00");
strcat(suppcode,itoa(supcode,s,10));
}
if (supcode>=99 && supcode<=999)
{
strcpy(suppcode,"S0");
strcat(suppcode,itoa(supcode,s,10));
}
if (supcode>=999 && supcode<=9999)
{
strcpy(suppcode,"S");
strcat(suppcode,itoa(supcode,s,10));
}
}
cout<<"The supplier code: "<<" "<<suppcode<<endl;
cout<<endl<<"Enter the first name of the supplier: ";
cin.get();
cin.getline(suppfname,20);
do
{
if (strlen(suppfname)==0)
{
cout<<endl<<"The first name of the supplier cannot be empty. Please enter the first name of the supplier. ";
cin.getline(suppfname,20);
}
else
{
break;
}
} while(strlen(suppfname)==0);
cout<<endl<<"Enter the last name of the supplier: ";
cin.getline(supplname,20);
do
{
if (strlen(supplname)==0)
{
cout<<"The last name of the supplier cannot be empty. Please enter the last name of the supplier. ";
cin.getline(supplname,20);
}
else
{
break;
}
} while(strlen(supplname)==0);
cout<<endl<<"Enter the address of the supplier: ";
cin.getline(suppaddress,20);
do
{
if (strlen(suppaddress)==0)
{
cout<<"The address of the supplier cannot be empty. Please enter the address of the supplier."<<endl;
cin.getline(suppaddress,20);
}
else
{
break;
}
} while(strlen(suppaddress)==0);
cout<<endl<<"Enter the city name of the supplier: ";
cin.getline(suppcity,20);
do
{
if (strlen(suppcity)==0)
{
cout<<"The city name of the supplier cannot be empty. Please enter the city name of the supplier."<<endl;
cin.getline(suppcity,20);
}
else
{
break;
}
} while(strlen(suppcity)==0);
cout<<endl<<"Enter the country name of the supplier: ";
cin.getline(suppcountry,20);
do
{
if (strlen(suppcountry)==0)
{
cout<<"The country name of the supplier cannot be empty. Please enter the country name of the supplier."<<endl;
cin.getline(suppcountry,20);
}
else
{
break;
}
} while(strlen(suppcountry)==0);
cout<<endl<<"Enter the zip code of the supplier: ";
cin.getline(suppzipcode,20);
do
{
if (strlen(suppzipcode)==0)
{
cout<<"The zip code of the supplier cannot be empty. Please enter the zip code of the supplier."<<endl;
cin.getline(suppzipcode,20);
}
else
{
break;
}
} while(strlen(suppcity)==0);
cout<<endl<<"Enter the email address of the supplier: ";
cin.getline(suppemailaddress,20);
if (strlen(suppemailaddress)==0)
{
cout<<endl<<"Do you want leave the e-mail address blank(y/n): ";
cin>>r;
if(r=='y')
{
strcpy(suppemailaddress," ");
}
}
cout<<endl<<"Enter the contact number of the supplier: ";
cin.getline(suppcontactnumber,20);
do
{
if (strlen(suppcontactnumber)==0)
{
cout<<"The contact number of the supplier cannot be empty. Please contact number of the supplier."<<endl;
cin.getline(suppcontactnumber,20);
}
else
{
break;
}
} while(strlen(suppcontactnumber)==0);
cout<<endl<<"Entering the following record in the Supplier module"<<endl;
cout<<"____________________________________________________"<<endl<<endl;
cout<<suppfname<<" "<<supplname<<" "<<suppaddress<<" "<<suppcity<<" "<<suppcountry<<" "<<suppzipcode<<" "<<suppemailaddress<<" "<<suppcontactnumber;
fstream addsupp("Supplier.txt",ios::out|ios::app);
addsupp.write( (char *)this, sizeof(class Supplier) );
addsupp.close();
cout<<endl<<endl<<"Do you want to enter another record (y/n)"<<endl;
cin>>ch;
}//closing the while loop.
suppauto.close();
}//closing the adddetails function.