Thread: Simple question - getline()

  1. #1
    Registered User
    Join Date
    Jan 2006

    Simple question - getline()

    Hey, I have a simple question.

    My test main:
    int main()
    	Player player;
    	string name;
    	cout << "Enter your name: ";
    	getline(cin, name);
    	cout << player.getName() << endl;
    	return 0;
    Everything works, but, when I fill the name in, getline ask for an extra <ENTER>. So when I input "Testname" followed by an enter, it displays a blank line and waits for an <ENTER> again. How can I make sure that it doesn't ask for that <ENTER> ?

  2. #2
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  3. #3
    Registered User
    Join Date
    Aug 2005
    Are you using VC6 ?

  4. #4
    Registered User
    Join Date
    Jan 2006
    OK thanks!

    I'm using Microsoft Visual C++ Enterprise edition, yes
    Last edited by QuietWhistler; 01-24-2006 at 01:18 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Simple class question
    By 99atlantic in forum C++ Programming
    Replies: 6
    Last Post: 04-20-2005, 11:41 PM
  2. Simple question about pausing program
    By Noid in forum C Programming
    Replies: 14
    Last Post: 04-02-2005, 09:46 AM
  3. simple question.
    By InvariantLoop in forum Windows Programming
    Replies: 4
    Last Post: 01-31-2005, 12:15 PM
  4. Binary Search Trees Part III
    By Prelude in forum A Brief History of
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  5. simple fgets question
    By theweirdo in forum C Programming
    Replies: 7
    Last Post: 01-27-2002, 06:58 PM