Thread: getline and string

  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    12

    getline and string

    hi

    i am using string in my program

    my problem is this

    i am using

    getline (cin , STR); // STR is the name of the string


    but when i run the program .....

    it require pressing "ENTER" two times

    one for inserting the text
    the other is for nothing

    may you help ?

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    VC++ 6.0 has a bug in this version of getline. Are you using VC++ 6.0?

    If not, can you post more of your code, preferably a complete and compilable example that demonstrates the problem.

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    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.*

  4. #4
    Registered User
    Join Date
    Oct 2007
    Posts
    12
    i used VC++ 6

    see the attachment

    rename it from

    *.cpp

    to

    *.zip

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    7,366
    There's no need to look at the code. There is a bug in VC++ 6.0. You need to fix the bug so that you don't have to hit enter twice (or upgrade to a modern compiler/library like VC++ 8.0).

    http://www.dinkumware.com/vc_fixes.html

    Scroll down to the part that says "Fix to <string>", then make the change to the string file that it mentions there. If you have questions about how to find or edit that file then ask them here.

  6. #6
    Registered User
    Join Date
    Oct 2007
    Posts
    12
    thanks

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question on getline and the string funtions
    By larry_2k4 in forum C Programming
    Replies: 5
    Last Post: 04-29-2009, 09:58 PM
  2. C++ ini file reader problems
    By guitarist809 in forum C++ Programming
    Replies: 7
    Last Post: 09-04-2008, 06:02 AM
  3. problem with string class, ifstream, and getline
    By deathbob in forum C++ Programming
    Replies: 9
    Last Post: 09-18-2005, 11:20 AM
  4. getline with string class in Borland C++
    By johnnyd in forum C++ Programming
    Replies: 6
    Last Post: 03-08-2003, 02:59 PM
  5. getline function with string class
    By brianptodd in forum C++ Programming
    Replies: 2
    Last Post: 03-05-2003, 09:03 AM