Thread: Strings????

  1. #1


    I'm having trouble getting strings from the user,

    cin >> info;

    User types: Misc info 1 2 3

    cout << info;

    output = Misc

    how do i store the whole sentence with spaces???


    [Borland Turbo C++ 3.0]

  2. #2
    #define MAX_BUFFER 100
    char info[MAX_BUFFER];

    cin.getline(info, MAX_BUFFER);

  3. #3
    I'm Back
    Join Date
    Dec 2001
    the >> and << operators ignore spaces and newlines.

    you'll have to do what the above posts says but i'll do it in the following way.


    this will exit if either 100 chars are inputed or enter is pressed, whichever is first.

    PS you should have posted this in the C or C++ forum.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Strings Program
    By limergal in forum C++ Programming
    Replies: 4
    Last Post: 12-02-2006, 03:24 PM
  2. Programming using strings
    By jlu0418 in forum C++ Programming
    Replies: 5
    Last Post: 11-26-2006, 08:07 PM
  3. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  4. damn strings
    By jmzl666 in forum C Programming
    Replies: 10
    Last Post: 06-24-2002, 02:09 AM
  5. menus and strings
    By garycastillo in forum C Programming
    Replies: 3
    Last Post: 04-29-2002, 11:23 AM