C++ not taking all inputs

I am creating a simple c++ program. To get Users input as string .My program is running fine but when i enter name with space console skip the next input here is my code.

#include <iostream>

using namespace std; // So the program can see cout and endl

class Etradehouse
{  
 private:
    string cnic,name,fname, dob,qua, des,join_date , number , address;
    int sal;    
 public:
     void getData(){ 
   cout<<"nPlease enter National identity Card number : n";
    cin >>cnic ; 
   cout<<"Please enter name: n";
   cin >> name; 
   cout<<"Please enter father name : n";
   cin >> fname; 
   cout<<"Please enter Date of birth : n";
   cin >> dob; 
   cout<<"Please enter qualification : n";
   cin >> qua; 
   cout<<"Please enter designation : n";
   cin >> des; 
  }
}; // Class ends here

int main()
{
 Etradehouse obj;
  obj.getData();  

}


Source: oop

Leave a Reply