how do i store charecters with spaces?

This is a discussion on how do i store charecters with spaces? within the C++ Programming forums, part of the General Programming Boards category; eg how do i do this! cin>>text; i then input "VOTE YES!"...

  1. #1
    Unregistered
    Guest

    how do i store charecters with spaces?

    eg how do i do this!

    cin>>text;

    i then input "VOTE YES!"

  2. #2
    Registered User
    Join Date
    Jan 2002
    Posts
    29
    char text[10];
    cout << "Enter something";
    cin >> text;

    i.e make text an array of char big enough to store the result.
    colin.

  3. #3
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    cin.getline ( text, TEXTLEN );
    Where TEXTLEN is the number of elements in your string. cin with the >> operator will use whitespace as a delimiter while getline uses a newline character.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Changing 3 spaces to tabs
    By dnguyen1022 in forum C Programming
    Replies: 2
    Last Post: 12-22-2008, 12:51 AM
  2. Fixing my program
    By Mcwaffle in forum C Programming
    Replies: 5
    Last Post: 11-05-2008, 03:55 AM
  3. Tabs or Spaces
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 46
    Last Post: 04-08-2007, 12:45 PM
  4. help, i cant count spaces or words
    By cdosrun in forum C Programming
    Replies: 2
    Last Post: 11-25-2005, 03:13 PM
  5. C - Reading first 20 charecters from file
    By ThoughtRiot in forum C Programming
    Replies: 7
    Last Post: 11-03-2002, 08:09 PM

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