getline() for string

This is a discussion on getline() for string within the C++ Programming forums, part of the General Programming Boards category; No, it doesn't work. cin.clear() clears the flag. But program still doesn't work....

  1. #16
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    No, it doesn't work.
    cin.clear() clears the flag. But program still doesn't work.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  2. #17
    すまん Hikaru's Avatar
    Join Date
    Aug 2006
    Posts
    46
    What's your code? I doubt I can help you, but I at least want to try figuring it out.

  3. #18
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    My code is what i've posted plus a cin.clear() before cin.get(). I better go for your suggestion and use substr().
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  4. #19
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    I don't know what I am doing tonight. After forgotting basic things. Now I see I placed the code in an infinite loop. The last problem was because of this. Thank you so much for your help. I didn't know about ctrl+z. Now I am using a string, a stream and rdbuf().
    The only thing I don't know is how to copy a stream into another.
    Thanks again.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  5. #20
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    What's wrong with the code in post #13?

  6. #21
    すまん Hikaru's Avatar
    Join Date
    Aug 2006
    Posts
    46
    Quote Originally Posted by siavoshkc
    I don't know what I am doing tonight. After forgotting basic things. Now I see I placed the code in an infinite loop. The last problem was because of this. Thank you so much for your help. I didn't know about ctrl+z. Now I am using a string, a stream and rdbuf().
    The only thing I don't know is how to copy a stream into another.
    Thanks again.
    I should be thanking you. I learned a lot by trying to find the answers to help.

  7. #22
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    What's wrong with the code in post #13?
    It puts cin into another stream indirectky. Is it possible to do it directly?
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

  8. #23
    Registered User
    Join Date
    Jan 2005
    Posts
    7,317
    Yes, with rdbuf, but you have to deal with finding the end of the stream issue. If you're fine with ctrl-z, then that's how you would do it.

  9. #24
    System Novice siavoshkc's Avatar
    Join Date
    Jan 2006
    Location
    Tehran
    Posts
    1,231
    And this is exactly what I am doing.
    Learn C++ (C++ Books, C Books, FAQ, Forum Search)
    Code painter latest version on sourceforge DOWNLOAD NOW!
    Download FSB Data Integrity Tester.
    Siavosh K C

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. getline() don't want to work anymore...
    By mikahell in forum C++ Programming
    Replies: 7
    Last Post: 07-31-2006, 10:50 AM
  2. getline problem
    By Bitphire in forum C++ Programming
    Replies: 5
    Last Post: 10-18-2004, 04:42 PM
  3. getline help
    By ProjectsProject in forum C++ Programming
    Replies: 3
    Last Post: 06-14-2004, 11:12 AM
  4. getline not working right
    By talz13 in forum C++ Programming
    Replies: 11
    Last Post: 12-10-2003, 10:46 PM
  5. getline with string class in Borland C++
    By johnnyd in forum C++ Programming
    Replies: 6
    Last Post: 03-08-2003, 01:59 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21