Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

getline(cin, s);

Posted on 2001-08-14
1
Medium Priority
?
347 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 200 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

This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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 pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
Suggested Courses
Course of the Month12 days, 16 hours left to enroll

971 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