#include<iostream>
#include<fstream>
using namespace std;
struct sign_up
{
char user_first_name[30];
char user_last_name[30];
int age;
char date_of_birthday[30];
int cnic_no;
char password[30];
char gender[30];
char email_address[30];
int phone_no;
char present_address[30];
char parmanent_address[30];
};
int main()
{
ofstream datafile("data.txt");
char choice;
sign_up data;
do
{
cout<<"Enter your first name";
cin>>data.user_first_name;
datafile<<"first name"<<data.user_first_name;
cout<<"Enter your last name";
cin>>data.user_last_name;
datafile<<"\n last name"<<data.user_last_name;
cout<<" Enter your birthday";
cin.ignore(30,'\n');
datafile<<"\n birthday" <<data.date_of_birthday;
cout<<"Enter your age";
cin>>data.age;
datafile<<"\n age"<<data.age;
cout<<"Enter your CNIC number ";
cin>>data.cnic_no;
datafile<<"\n cnic"<<data.cnic_no;
cout<<"Enter your phone number";
cin>>data.phone_no;
datafile<<"\n phone.no"<<data.phone_no;
cout<<"Enter your email address";
cin.ignore(30,'\n');
datafile<<"\n email address"<<data.email_address;
cout<<"Enter your present address";
cin.ignore(30,'\n');
datafile<<"\n present address"<<data.present_address;
cout<<"Enter your permanent address";
cin.ignore(30,'\n');
datafile<<"\n permanent address"<<data.parmanent_address;
cout<<"Enter your desired password";
cin.ignore(30,'\n');
datafile<<"\n password"<<data.password;
datafile.close();
cout<<"press y to make another account and any other character to exit";
cin>>choice;
}
while(choice=='y');
return 0;
}
in this program after cin.ignore i get two inputs at a time.
please anybody solve it!
You can try the cin.ignore stream size from the limits header file or you can use a dummy variable to eat up the input buffer and not one of your cin operations.