How do you put spaces in between phrases?

This is a discussion on How do you put spaces in between phrases? within the C++ Programming forums, part of the General Programming Boards category; I seem to have run into a problem...and i havent found the answer yet... char name1[](""); using that i allow ...

  1. #1
    Inez
    Guest

    How do you put spaces in between phrases?

    I seem to have run into a problem...and i havent found the answer yet...



    char name1[]("");

    using that i allow the user to input a 'name' but the name can never be above 1 word...not only does it not record the other words but it will cause the program to loop several times...how do you fix this!?

  2. #2
    S­énior Member
    Join Date
    Jan 2002
    Posts
    982
    >char name1[]("");

    That will allocate enough storage for the terminating NULL and nothing else, you'll have to give the array a size or use an STL string.

    To read characters that are seperated by white space you could use cin.get(), cin.getline(), scanf() or fgets(). If you want more specific help post your code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Saving spaces in arrays?
    By alexnb185 in forum C Programming
    Replies: 6
    Last Post: 11-23-2007, 11:53 AM
  2. Tabs or Spaces
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 46
    Last Post: 04-08-2007, 12:45 PM
  3. white spaces ...
    By eagles in forum C++ Programming
    Replies: 6
    Last Post: 01-13-2006, 07:55 AM
  4. saving a CString to binary file with trailing spaces
    By nineofhearts in forum C++ Programming
    Replies: 12
    Last Post: 01-03-2006, 11:53 AM
  5. help, i cant count spaces or words
    By cdosrun in forum C Programming
    Replies: 2
    Last Post: 11-25-2005, 03:13 PM

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