getline non-member still doesn't work? 
Author Message
 getline non-member still doesn't work?

Hello,

Is it just me or after several C++ compiler versions, service pack 4, and
publication of the problem in a popular 1998 C++ textbook, Microsoft still
hasn't fixed the getline bug.  They did fix the getline istream method in
version 6 which previously had exactly the same problem, but no fix on the
getline non-member function.  In the code below each getline should return
as soon as the ENTER key is struck but instead an extra line must be
entered.  The second getline doesn't work at all.  Could someone having
access to something other than a Microsoft compiler try this code and let me
know if it works correctly.

Has anyone out there rewritten their own version of this function that works
correctly?

Thanks,
Ray Mitchell

#include <iostream>
#include <string>
using namespace std;

int main()
{
        string str;

        cout << "Input a string: ";
        getline(cin, str);
        cout << str << endl;

        cout << "Input another string: ";
        getline(cin, str);
        cout << str << endl;

        return(0);

Quote:
}



Wed, 26 Feb 2003 13:28:48 GMT  
 getline non-member still doesn't work?
The fixes are at www.dinkumware.com


Quote:
> Hello,

> Is it just me or after several C++ compiler versions, service pack 4, and
> publication of the problem in a popular 1998 C++ textbook, Microsoft still
> hasn't fixed the getline bug.  They did fix the getline istream method in
> version 6 which previously had exactly the same problem, but no fix on the
> getline non-member function.  In the code below each getline should return
> as soon as the ENTER key is struck but instead an extra line must be
> entered.  The second getline doesn't work at all.  Could someone having
> access to something other than a Microsoft compiler try this code and let
me
> know if it works correctly.

> Has anyone out there rewritten their own version of this function that
works
> correctly?

> Thanks,
> Ray Mitchell

> #include <iostream>
> #include <string>
> using namespace std;

> int main()
> {
>         string str;

>         cout << "Input a string: ";
>         getline(cin, str);
>         cout << str << endl;

>         cout << "Input another string: ";
>         getline(cin, str);
>         cout << str << endl;

>         return(0);
> }



Wed, 26 Feb 2003 14:01:18 GMT  
 getline non-member still doesn't work?
Thanks Erik,

Isn't it kind of rediculous that the first thing you have to do after laying
out good money for a product is to lay out even more to get it to work!


Quote:
> The fixes are at www.dinkumware.com



> > Hello,

> > Is it just me or after several C++ compiler versions, service pack 4,
and
> > publication of the problem in a popular 1998 C++ textbook, Microsoft
still
> > hasn't fixed the getline bug.  They did fix the getline istream method
in
> > version 6 which previously had exactly the same problem, but no fix on
the
> > getline non-member function.  In the code below each getline should
return
> > as soon as the ENTER key is struck but instead an extra line must be
> > entered.  The second getline doesn't work at all.  Could someone having
> > access to something other than a Microsoft compiler try this code and
let
> me
> > know if it works correctly.

> > Has anyone out there rewritten their own version of this function that
> works
> > correctly?

> > Thanks,
> > Ray Mitchell

> > #include <iostream>
> > #include <string>
> > using namespace std;

> > int main()
> > {
> >         string str;

> >         cout << "Input a string: ";
> >         getline(cin, str);
> >         cout << str << endl;

> >         cout << "Input another string: ";
> >         getline(cin, str);
> >         cout << str << endl;

> >         return(0);
> > }



Wed, 26 Feb 2003 14:03:11 GMT  
 getline non-member still doesn't work?

Greets,

    In all fairness, the Visual C++ and its STL libraries have been around
for quite some time now.  I won't go into specifics, however, history has
shown people tend to quickly get up in arms about this particular situation
without knowing the full story.  What is important to note is that you do
not *need* to 'purchase' newer and more improved Dinkumware STL to fix this
problem.  (Although there is certainly nothing wrong with getting something
a bit more up to date.)  Point your browser to:

http://www.dinkumware.com/vc_fixes.html

    Here you will find the fixes you can apply to your STL code.  (The one
with which you are concerned is the "Fix to <string>".  (I am assuming this
since you said the non-member getline(), it too has a lookahead problem.)  I
would recommend that before you do apply any of these changes, that you
update your Visual Studio installation to the latest service pack.
(Currently SP4.)

Regards,

Joe


Quote:
> Thanks Erik,

> Isn't it kind of rediculous that the first thing you have to do after
laying
> out good money for a product is to lay out even more to get it to work!



> > The fixes are at www.dinkumware.com



> > > Hello,

> > > Is it just me or after several C++ compiler versions, service pack 4,
> and
> > > publication of the problem in a popular 1998 C++ textbook, Microsoft
> still
> > > hasn't fixed the getline bug.  They did fix the getline istream method
> in
> > > version 6 which previously had exactly the same problem, but no fix on
> the
> > > getline non-member function.  In the code below each getline should
> return
> > > as soon as the ENTER key is struck but instead an extra line must be
> > > entered.  The second getline doesn't work at all.  Could someone
having
> > > access to something other than a Microsoft compiler try this code and
> let
> > me
> > > know if it works correctly.

> > > Has anyone out there rewritten their own version of this function that
> > works
> > > correctly?

> > > Thanks,
> > > Ray Mitchell

> > > #include <iostream>
> > > #include <string>
> > > using namespace std;

> > > int main()
> > > {
> > >         string str;

> > >         cout << "Input a string: ";
> > >         getline(cin, str);
> > >         cout << str << endl;

> > >         cout << "Input another string: ";
> > >         getline(cin, str);
> > >         cout << str << endl;

> > >         return(0);
> > > }



Wed, 26 Feb 2003 20:01:22 GMT  
 getline non-member still doesn't work?
In addition to the good answers provided by others here, let me also
suggest you consider using STLPort (http://www.stlport.org).  I use
(and like) the DinkumWare commercial release but STLPort is an
excellent alternative.

Joe O'


Quote:
> Hello,

> Is it just me or after several C++ compiler versions, service pack
4, and
> publication of the problem in a popular 1998 C++ textbook, Microsoft
still
> hasn't fixed the getline bug.  They did fix the getline istream
method in
> version 6 which previously had exactly the same problem, but no fix
on the
> getline non-member function.  In the code below each getline should
return
> as soon as the ENTER key is struck but instead an extra line must be
> entered.  The second getline doesn't work at all.  Could someone
having
> access to something other than a Microsoft compiler try this code
and let me
> know if it works correctly.



Thu, 27 Feb 2003 02:39:50 GMT  
 getline non-member still doesn't work?
You don't have to lay out any money.  Go to the support page and apply the
STL fixes that they provide for free.


Quote:
> Thanks Erik,

> Isn't it kind of rediculous that the first thing you have to do after
laying
> out good money for a product is to lay out even more to get it to work!



> > The fixes are at www.dinkumware.com



> > > Hello,

> > > Is it just me or after several C++ compiler versions, service pack 4,
> and
> > > publication of the problem in a popular 1998 C++ textbook, Microsoft
> still
> > > hasn't fixed the getline bug.  They did fix the getline istream method
> in
> > > version 6 which previously had exactly the same problem, but no fix on
> the
> > > getline non-member function.  In the code below each getline should
> return
> > > as soon as the ENTER key is struck but instead an extra line must be
> > > entered.  The second getline doesn't work at all.  Could someone
having
> > > access to something other than a Microsoft compiler try this code and
> let
> > me
> > > know if it works correctly.

> > > Has anyone out there rewritten their own version of this function that
> > works
> > > correctly?

> > > Thanks,
> > > Ray Mitchell

> > > #include <iostream>
> > > #include <string>
> > > using namespace std;

> > > int main()
> > > {
> > >         string str;

> > >         cout << "Input a string: ";
> > >         getline(cin, str);
> > >         cout << str << endl;

> > >         cout << "Input another string: ";
> > >         getline(cin, str);
> > >         cout << str << endl;

> > >         return(0);
> > > }



Thu, 27 Feb 2003 08:40:27 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. string::getline doesn't work with cin?

2. Non-modal dialog in AFXDLL doesn't work

3. ListBox FindString member doesn't work

4. SaveBarState (WORKS) LoadBarState(Doesn't Work)?

5. GetPrivateProfileSectionNames works in 2000, doesn't work in 98 or ME

6. CEdit don't work at GetLine() well

7. Tooltip works and then doesn't work

8. Q147740 CWnd work-around doesn't work with control that uses lic file

9. Calling ADO's GetRows() from VC doesn't work

10. Don't know why this doesn't work, but

11. TERMWAIT Win 3.1 sample doesn't work under '95

12. Timer Callback doesn't have access to member data

 

 
Powered by phpBB® Forum Software