Thread: String input

  1. #1
    Registered Usurer
    Join Date
    Apr 2005
    Location
    upstate NY
    Posts
    79

    String input

    I've been searching for the answer to this question, but no luck so far -

    How can I input strings like

    Bach, Johann Sebastian

    Mozart, Wolfgang Amadeus ??

    I'm sure there's a way to include spaces in a string but I'm at a loss here.

    (For the inevitable 'read the FAQ' posters, please help me find it!)

    Thanks -

    -JM

  2. #2
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    http://faq.cprogramming.com/cgi-bin/...&id=1043284385
    fgets will read until a newline (\n) or EOF is reached.

    Edit edit: This is C++; Use:
    std::istream::getline
    std::getline

    The first being compatible for char*, second for std::string's
    Last edited by Tonto; 09-11-2005 at 12:56 PM.

  3. #3
    Registered Usurer
    Join Date
    Apr 2005
    Location
    upstate NY
    Posts
    79
    Cool - thank you!

    edit - Ah, even better! Thanks again-
    Last edited by -JM; 09-11-2005 at 02:07 PM. Reason: update

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. char Handling, probably typical newbie stuff
    By Neolyth in forum C Programming
    Replies: 16
    Last Post: 06-21-2009, 04:05 AM
  2. Replies: 14
    Last Post: 01-18-2008, 04:14 PM
  3. Replies: 4
    Last Post: 03-03-2006, 02:11 AM
  4. can anyone see anything wrong with this code
    By occ0708 in forum C++ Programming
    Replies: 6
    Last Post: 12-07-2004, 12:47 PM
  5. lvp string...
    By Magma in forum C++ Programming
    Replies: 4
    Last Post: 02-27-2003, 12:03 AM