Connecting Tech Pros Worldwide Forums | Help | Site Map

getline problem

solartimba
Guest
 
Posts: n/a
#1: Jul 22 '05
/* 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);
}

Leor Zolman
Guest
 
Posts: n/a
#2: Jul 22 '05

re: getline problem


On 6 Apr 2004 10:37:16 -0700, kaferro@hotmail.com (solartimba) wrote:
[color=blue]
>/* 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);
>}[/color]

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
Leor Zolman
Guest
 
Posts: n/a
#3: Jul 22 '05

re: getline problem


On 6 Apr 2004 10:37:16 -0700, kaferro@hotmail.com (solartimba) wrote:
[color=blue]
>/* 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);
>}[/color]

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
Closed Thread


Similar C / C++ bytes