Thread: just another text input question...

  1. #1
    Registered User
    Join Date
    Mar 2003
    Posts
    40

    just another text input question...

    ...probably a stupid one...

    ...I am trying to read in many lines of text and so far I can get the program to read in one line and that is it...using ifstream for file input...I am trying to tell it to read all lines until the end of the file...or some string that separates the files...then I wish to save what it has read into a vector....is there anything else apart from getline??...

    ...I realise this might be something very simple but we all have to start somewhere right??...

    ...I had tried to save each line....and append them together to then save all in a vector..am I totally off??...

    ...thank you so very much...
    ..."GSXR1300"...

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Here's a snippet for you
    Code:
    vector<string> v;
    string str;
    
    while (getline(cin, str))
        v.push_back(str);
    Post some code when you have troubles.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Mar 2003
    Posts
    40
    ...you know what?...I was not putting the getline in a while loop...thank you that solved that problem... ...you the coolest...
    ..."GSXR1300"...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 14
    Last Post: 01-18-2008, 04:14 PM
  2. About aes
    By gumit in forum C Programming
    Replies: 13
    Last Post: 10-24-2006, 03:42 PM
  3. Structure and Linked List User Input Question
    By kevndale79 in forum C Programming
    Replies: 16
    Last Post: 10-05-2006, 11:09 AM
  4. LaTeX Question: Displaying Text and Images
    By Reisswolf in forum Tech Board
    Replies: 0
    Last Post: 06-30-2006, 08:01 AM
  5. Help on restricting input to a numbers only (or text only)
    By BongoBob in forum C++ Programming
    Replies: 6
    Last Post: 05-14-2006, 08:32 PM