getline problem

S

solartimba

/* 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);
}
 
L

Leor Zolman

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top