mercredi 29 mars 2017

Program doesn`t allow me to enter data and skips to the next line

  class Products
{
char Part_Name[100];
char Manufac_Name[100];
char GenSpecific[100];
char SocketType[100];
float Price;
public:
void Add();
void CpuAdd();
void CpuAddGetdata();
}Prod;



void Products::CpuAdd()
{
system("cls");
cout << " ";
cout << " Enter Manufacturer Name :\n";
cin.getline(Manufac_Name, 100);
cout << " Enter Complete Product Name :\n";
cin.getline(Part_Name, 100);
cout << " Enter Generation Number ( Intel ) or Series ( AMD ) :\n";
cin.getline(GenSpecific, 100);
cout << " Enter Socket Requirement Type :\n";
cin.getline(SocketType, 100);
cout << " Enter Price :\n";
cin >> Price;
cout << endl << endl << "Value Entered successfully";
}


 void Products::Add()                                                                   
{
int ProdChoice;
cin >> ProdChoice;

switch (ProdChoice)
{
case 1:
    Prod.CpuAdd();    // It`s here where the main problem begins.
    break;
}






void Manager::Manager_In()                             
{
  .
  .
  .
  int Manager_In_Choice;
cin >> Manager_In_Choice;

switch (Manager_In_Choice)
{
case 1:                                                                     
    Prod.Add();         // It works even till here properly.                                        
    break;  
}       

void Manager::Welcome_Login()
{
  .
  .
  .
  Man.Manager_In();   // called a function. It works perfectly till here.
  .
  .
  .
}

void User()
{
int userx;
cin >> userx;

switch (userx)
{
case 1: 
    Man.Welcome_Login();                                                    
    break;
}

int main()
{
User();
return 0;
}

I used breakpoints as well and tried to figure out what was going on but when i typed a similar code again but with directly calling the CpuAdd function it kind of worked. But now when i am working on a big program and i am calling it after a lot of steps it skips the cin.getline(Manufac_Name, 100).

Program in execution

Aucun commentaire:

Enregistrer un commentaire