std::getline problems

This is a discussion on std::getline problems within the C++ Programming forums, part of the General Programming Boards category; Hi guys, here i am again with a problem. i am having a problem with std::getline. In my program, it ...

  1. #1
    Registered User
    Join Date
    Sep 2007
    Posts
    32

    std::getline problems

    Hi guys, here i am again with a problem.

    i am having a problem with std::getline. In my program, it made no compile time errors, but when i run it, all it do is skip over the actual line, and run whats on the next line.

    and btw, can someone tell me if they know a good free cpp debugger.

  2. #2
    Sweet
    Join Date
    Aug 2002
    Location
    Tucson, Arizona
    Posts
    1,801
    Post code.

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,485
    Sounds like you've done

    cin >> someVar;

    then followed it with a getline()

    I suppose this is where you would use something like
    cin.ignore()
    There are many examples of it's usage on the board.

    Of course, the better answer would be to always use getline to read input into a string, then perform whatever validation and conversion was appropriate on that string.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  4. #4
    Registered User
    Join Date
    Oct 2007
    Posts
    36
    this wont work out smoothly...

    As suggested, POST CODE

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by _lazycat_ View Post
    and btw, can someone tell me if they know a good free cpp
    debugger.
    What compiler are you using? Most compiler packages come with a suitable debugger.

    You can get Visual Studio 2005 for free from Microsoft, which comes with a good debugger. Or if you want a Free Software model debugger, gdb is an option.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. No clue how to make a code to solve problems!
    By ctnzn in forum C Programming
    Replies: 8
    Last Post: 10-16-2008, 02:59 AM
  2. String Manipulation problems -_-
    By Astra in forum C Programming
    Replies: 5
    Last Post: 12-13-2006, 04:48 PM
  3. Rendering problems (DirectX?)
    By OnionKnight in forum Tech Board
    Replies: 0
    Last Post: 08-17-2006, 12:17 PM
  4. contest problems on my site
    By DavidP in forum Contests Board
    Replies: 4
    Last Post: 01-10-2004, 08:19 PM
  5. DJGPP problems
    By stormswift in forum C Programming
    Replies: 2
    Last Post: 02-26-2002, 03:35 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21