Thread: Getline fucntion

  1. #1
    Registered User
    Join Date
    Nov 2005
    Posts
    7

    Question Getline fucntion

    Im trying to allow the user to type in a name that can have spaces like "First Last". When I use getline, it requires the user to hit return twice. For example, he/she types in the name and hits return to enter it, then has to hit it again, I have no idea why. Is there anyway to make it so that the user can just hit return once?



    Code:
        string charactername;
    	cout << "Please enter a name for your character: ";
    	getline(cin,charactername);

    I've tried simply

    Code:
    cin >> charactername;
    but it messes up the entire program afterwards...

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,820
    Woop?

  3. #3
    Registered User
    Join Date
    Apr 2003
    Posts
    2,663
    It's a bug in the compiler. You can fix it easily, but unfortunately the MSDN description doesn't tell you what file has the errror in it. I found it in:

    C:\Program Files\C++Microsoft Visual Studio\VC98\Include\String

  4. #4
    ^ Read Backwards^
    Join Date
    Sep 2005
    Location
    Earth
    Posts
    282

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getline() don't want to work anymore...
    By mikahell in forum C++ Programming
    Replies: 7
    Last Post: 07-31-2006, 10:50 AM
  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 with string class in Borland C++
    By johnnyd in forum C++ Programming
    Replies: 6
    Last Post: 03-08-2003, 02:59 PM