Solved

getline(cin, s);

Posted on 2001-08-14
1
328 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
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 viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

617 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