Thread: my getline funtion is not working?

  1. #1
    Registered User
    Join Date
    Aug 2009
    Posts
    34

    my getline funtion is not working?

    It just skips to the next cout...
    Code:
    
    #include <iostream>
    #include <cstdlib>
    #include <string>
    using namespace std;
    
    // SavingsAccount class definition
    class SavingsAccount
    {
    private:
       int accountType;
       string ownerName;
       long ssn;
       double accountClosurePenaltyPercent, accountBalance;
    
    public:
       void initializeMembers()
       {
         
          
          cout << "Please enter Account Type ( 1, 2, or 3 ): ";
          cin >> accountType;
          cout << "\nPlease enter owner's name: ";
          getline(cin, ownerName);
          cout << "\nPlease enter owner's SS number without dashes: ";
          cin >> ssn;
          cout << "\nPlease enter Accout Closure Penalty Percent: ";
          cin >> accountClosurePenaltyPercent;
          cout << "\nPlease enter Account Balance: ";
          cin >> accountBalance;
       }
    };

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    This is a common problem that has already come up twice in the last two days...

    cin.getline not pausing function so user can enter input???

    The solution is the same for your problem as in that thread.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. return value for global getline method
    By danglingelse in forum C++ Programming
    Replies: 1
    Last Post: 01-07-2005, 02:54 PM
  2. getline problem
    By Bitphire in forum C++ Programming
    Replies: 5
    Last Post: 10-18-2004, 04:42 PM
  3. getline help
    By ProjectsProject in forum C++ Programming
    Replies: 3
    Last Post: 06-14-2004, 11:12 AM
  4. getline not working right
    By talz13 in forum C++ Programming
    Replies: 11
    Last Post: 12-10-2003, 11:46 PM
  5. getline problem
    By jriano in forum C++ Programming
    Replies: 3
    Last Post: 06-24-2003, 10:05 PM