getline(cin, str_Var, '\n') doesn't work

Sharky Forums


Results 1 to 3 of 3

Thread: getline(cin, str_Var, '\n') doesn't work

  1. #1
    Tiger Shark
    Join Date
    Oct 2000
    Location
    Phila, PA
    Posts
    519

    Post getline(cin, str_Var, '\n') doesn't work

    HI, guys, once again I have a problem for which i'm seeking a solution.
    I'm writing a program, a part of which prompts a user to enter "title" and "Author" as strings.
    I'm using getline(cin, str_Var, '\n') like this:
    cout<<"Enter Title: ";
    getline(cin, str_Var, '\n');
    str_Title=str_Var;
    cout<<"Enter Author: ";
    getline(cin, str_Var, '\n');
    str_Author=str_Var;

    When the program runs I have to press "ENTER" twice to pass the first getline operator, and it doesn't save the str_var to str_title, but put's it into str_author after secong getline...

    I tried using cin.ignore();
    but that doesn't help.
    I also installed SP5 for vis studio 6...

    HELP PLEASE this thing is killing me !

    ------------------
    There are no stupid questions, there are stupid answers.
    There are no stupid questions, there are stupid answers.

  2. #2
    Mako Shark dighn's Avatar
    Join Date
    Nov 2000
    Location
    Vancouver, BC Canada
    Posts
    3,171

    Post

    that's a known bug... vc++ isn't the best compiler *sigh*

    this tells u how to fix it http://www.msoe.edu/~taylor/resources/msvc60.htm

    ------------------
    So easy to use, no wonder it's number one!!!
    Where do you want to go today?
    Member of NT Jocks
    Tesla coils are not weapons
    .

  3. #3
    Tiger Shark
    Join Date
    Oct 2000
    Location
    Phila, PA
    Posts
    519

    Post

    Hey, thanks man. Too bad i can't change this file here in college, but I'll try it at home.

    ------------------
    There are no stupid questions, there are stupid answers.
    There are no stupid questions, there are stupid answers.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •