You are currently offline, waiting for your internet to reconnect

The getline template function reads an extra character after encountering the delimiter

Symptoms
The Standard C++ Library template getline function reads an extra character after encountering the delimiter. Please refer to the sample program in the More Information section for details.
Resolution
Modify the getline member function, which can be found in the following system header file string, as follows:
	else if (_Tr::eq((_E)_C, _D))                {_Chg = true;              //  _I.rdbuf()->snextc(); /* Remove this line and add the line below.*/ 		  _I.rdbuf()->sbumpc();                break; }				
Note Because the resolution involves modifying a system header file, extreme care should be taken to ensure that nothing else is changed in the header file. Microsoft is not responsible for any problems resulting from unwanted changes to the system header files.
Status
Microsoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.This problem was corrected in Microsoft Visual C++ .NET.
More information
The following sample program demonstrates the bug:
//test.cpp//Compiler options : /GX#include <string>#include <iostream>int main () {	std::string s,s2;	std::getline(std::cin,s);	std::getline(std::cin,s2);	std::cout << s <<'\t'<< s2 << std::endl;	return 0;}Actual Results:Hello<Enter Key>World<Enter Key><Enter Key>	Hello   WorldExpected Results:Hello<Enter Key>World<Enter Key>Hello   World				
STL
Properties

Article ID: 240015 - Last Review: 06/19/2014 06:10:00 - Revision: 4.0

  • kbtshoot kbprb kbbug kbfix kblangcpp kbnoupdate kbstl kbtemplate KB240015
Feedback