CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2002
    Posts
    96

    Input string problems - urgent !!!

    I have to ask the user to enter a value which he could leave empty if he wishes to.
    If I use cin, it is required that he enter something at least
    getch() - when he uses backspace, the character is not deleted
    getline - requires him to press enter twice
    scanf - requires him to enter something at least
    gets - sometimes the program skips the code.

    could somebody help me out with this,
    Shilpi

  2. #2
    Join Date
    Mar 2002
    Location
    California
    Posts
    1,582
    getline - requires him to press enter twice
    This is a bug with the library. Unfortunately, I'm not sure how to fix it. Maybe somebody else can enlighten us...

    Jeff

  3. #3
    Join Date
    May 2000
    Location
    Phoenix, AZ [USA]
    Posts
    1,347
    If you're using Visual Studio 6.0 or less, check out this page,
    which gives many bug fixes to "tide you over" until Visual
    Studio .NET: http://www.dinkumware.com/vc_fixes.html

    In particular:
    The header <istream> contains a definition for member function basic_istream::getline. It has a lookahead problem -- typing a delimiter to end the input doesn't return control until you type yet another character. Change the code as indicated by the comment:
    Code:
        else if (_C == _Di)
            {++_Chcount;
            rdbuf()->snextc();    // replace snextc with sbumpc
            break; }
    Note that V6.0 replaces snextc with stossc. It is an adequate fix, but you can also apply the above patch safely.
    --Paul

  4. #4
    Join Date
    Mar 2002
    Posts
    96
    Why is it that sometimes, my program does not ask the user for input even if I have used gets();
    Thanks, Shilpi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured