getline problem

Discussion in 'C++' started by solartimba, Apr 6, 2004.

  1. solartimba

    solartimba Guest

    /* 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);
    }
    solartimba, Apr 6, 2004
    #1
    1. Advertising

  2. solartimba

    Leor Zolman Guest

    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
    Leor Zolman, Apr 6, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John
    Replies:
    10
    Views:
    10,030
    Buster Copley
    Jul 14, 2003
  2. Poof
    Replies:
    1
    Views:
    372
  3. Joe
    Replies:
    4
    Views:
    7,738
    Chris Theis
    Jan 22, 2004
  4. Alex

    getline problem

    Alex, Jun 5, 2004, in forum: C++
    Replies:
    6
    Views:
    500
    Victor Bazarov
    Jun 6, 2004
  5. bg

    problem with getline

    bg, Jun 26, 2004, in forum: C++
    Replies:
    1
    Views:
    502
    David Harmon
    Jun 26, 2004
Loading...

Share This Page