Solved

getline(cin, s);

Posted on 2001-08-14
1
293 Views
Last Modified: 2006-11-17
This code when compiled in VC++ 6.0 shows a bug in VC++ 6.0, the bug here is that you have to press <enter> twice to enter something with the keyboard, the same code functions correctly with borland c++ builder 5.0. Any idea if this is solved by microsoft? I find searching their website a disaster!

#include <string>
#include <iostream>

using namespace std;

int main() {
     string s;
     getline(cin, s);
     cout << s << endl;
     return 0;
}
0
Comment
Question by:barzangy
1 Comment
 
LVL 86

Accepted Solution

by:
jkr earned 50 total points
ID: 6384038
This is indeed a known bug - see http://support.microsoft.com/support/kb/articles/Q240/0/15.ASP ('BUG: getline Template Function Reads Extra Character'). There's also a fix provided with that article.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now