0

I have tried all methods to get string input that have spaces in c++ , here is what i have tried so far

       string  CustomerinputNumber ;
    string CustomerName = "";       
     string CustomerAddress = "";
    string CustomerContactNo = "";
     ofstream myfile;
      myfile.open ("Customer.txt", std::ios_base::app);     
    cout << "Customer Identification Number : ";        
    cin>>CustomerinputNumber; 
    cout << "Customer Name : ";
     getline(cin, CustomerName);
    cout << "Customer Address : ";
        cin>> CustomerAddress;
       cout << "Customer Contact Number : ";
    cin>> CustomerContactNo;

and other methods

         std::string line;
         getline(cin, line);

but when I enter space it assign the value to next cin>>var variable so this question may be marked as duplicate but trust me I found no solution. So can any body tell me how to get string with spaces as input in c++ like

 Enter value: wasif albert green

 value is   : wasif albert green

0 Answers0