Microsoft KB Archive/240015

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

Article ID: 240015

Article Last Modified on 9/2/2005

-

APPLIES TO

 The Standard C++ Library, when used with:  Microsoft Visual C++ 6.0 Enterprise Edition

 Microsoft Visual C++ 6.0 Professional Edition

 Microsoft Visual C++ 6.0 Standard Edition 

-

<div class="notice_section">

This article was previously published under Q240015

<div class="symptoms_section">

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.

<div class="resolution_section">

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.

<div class="status_section">

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.

<div class="moreinformation_section">

MORE INFORMATION
The following sample program demonstrates the bug: //test.cpp //Compiler options : /GX 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; }
 * 1) include
 * 2) include

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

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

Additional query words: STL

Keywords: kbtshoot kbbug kbfix kbnoupdate kblangcpp kbtemplate kbstl kbprb KB240015

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.