String input

This is a discussion on String input within the C++ Programming forums, part of the General Programming Boards category; I've been searching for the answer to this question, but no luck so far - How can I input strings ...

  1. #1
    -JM
    -JM is offline
    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
    -JM
    -JM is offline
    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, 03:14 PM
  3. Replies: 4
    Last Post: 03-03-2006, 01:11 AM
  4. can anyone see anything wrong with this code
    By occ0708 in forum C++ Programming
    Replies: 6
    Last Post: 12-07-2004, 11:47 AM
  5. lvp string...
    By Magma in forum C++ Programming
    Replies: 4
    Last Post: 02-26-2003, 11:03 PM

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