Solved

getline(cin, s);

Posted on 2001-08-14
1
317 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
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…

710 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