Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > getline problem

Reply
Thread Tools

getline problem

 
 
solartimba
Guest
Posts: n/a
 
      04-06-2004
/* The cout<<name<<endl; statement outputs the string "name"
of the previous input. Whats is wrong. */
/* pc MS c++ 5.0*/


#include <string>
#include <iostream>
using namespace std;
int main()
{
string name;
name =" as";
while (!(name.empty()))
{
cout<<" enter name : "<<endl;
getline(cin,name);
cout<<name<<endl;

}
cout<<"ok "<< name<<endl;
return (0);
}
 
Reply With Quote
 
 
 
 
Leor Zolman
Guest
Posts: n/a
 
      04-06-2004
On 6 Apr 2004 10:37:16 -0700, (solartimba) wrote:

>/* The cout<<name<<endl; statement outputs the string "name"
> of the previous input. Whats is wrong. */
>/* pc MS c++ 5.0*/
>
>
>#include <string>
>#include <iostream>
>using namespace std;
>int main()
>{
> string name;
> name =" as";
> while (!(name.empty()))
> {
> cout<<" enter name : "<<endl;
> getline(cin,name);
> cout<<name<<endl;
>
> }
> cout<<"ok "<< name<<endl;
> return (0);
>}


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

(search for "getline")
-leor

--
Leor Zolman --- BD Software --- www.bdsoft.com
On-Site Training in C/C++, Java, Perl and Unix
C++ users: Download BD Software's free STL Error Message Decryptor at:
www.bdsoft.com/tools/stlfilt.html
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem with getline bg C++ 1 06-26-2004 10:15 PM
getline problem Alex C++ 6 06-06-2004 02:07 AM
ifstream getline() Problem ... Joe C++ 4 01-22-2004 03:31 PM
ifstream getline() problem John C++ 10 07-14-2003 04:47 PM
Problem with cin.getline(); Poof C++ 1 07-11-2003 01:14 PM



Advertisments