Microsoft small business knowledge base

Article ID: 240015 - Last Review: June 19, 2014 - Revision: 4.0


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.


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.*/ 
                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.


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:
//Compiler options : /GX
#include <string>
#include <iostream>
int main () {
	std::string s,s2;
	std::cout << s <<'\t'<< s2 << std::endl;
	return 0;

Actual Results:
Hello<Enter Key>
World<Enter Key>
<Enter Key>	
Hello   World

Expected Results:
Hello<Enter Key>
World<Enter Key>
Hello   World
kbtshoot kbprb kbbug kbfix kblangcpp kbnoupdate kbstl kbtemplate KB240015
Additional support options
Ask The Microsoft Small Business Support Community
Contact Microsoft Small Business Support
Find Microsoft Small Business Support Certified Partner
Find a Microsoft Store For In-Person Small Business Support