Storing multi line text

This is a discussion on Storing multi line text within the C Programming forums, part of the General Programming Boards category; Can someone tell me how I would store multi line text? eg Code: char *text = "AAA [Date] BBB [Time]" ...

  1. #1
    Registered User
    Join Date
    Apr 2007
    Posts
    30

    Storing multi line text

    Can someone tell me how I would store multi line text?

    eg

    Code:
    char *text = "AAA [Date]
    BBB [Time]"
    or

    Code:
    char text[] = {AAA [Date]
    BBB [Time]};
    Also, how do I escape '['??

    Thanks

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    Code:
    char text[] = "AAA [Date]\nBBB[Time]";
    Haven't you used '\n' in printf() before?

  3. #3
    Registered User
    Join Date
    Apr 2007
    Posts
    30
    What if I have huge amount of text? Do I need to aaa\nbbb\nccc\n ?? Is that the only way?

  4. #4
    Registered User
    Join Date
    Oct 2006
    Location
    Canada
    Posts
    1,243
    if you have a 'huge' amount of text maybe read it in from a file

  5. #5
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,211
    And if it's incredibly huge and requires a file, don't bother storing it in one array like that.

  6. #6
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    Code:
    char *text = "AAA [Date]"
                 "BBB [Time]";
    the strings will be joined together as if you wrote:
    Code:
    char *text = "AAA [Date]BBB [Time]";

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. text between the line
    By munna_dude in forum Linux Programming
    Replies: 1
    Last Post: 10-17-2007, 01:46 AM
  2. how do you read a whole line of text from a txt file
    By themexican in forum C++ Programming
    Replies: 3
    Last Post: 10-18-2005, 10:17 AM
  3. How do I make my edit box move text to the next line?
    By ElWhapo in forum Windows Programming
    Replies: 2
    Last Post: 01-04-2005, 11:21 PM
  4. Output text containing '\r' as new line character.
    By anonytmouse in forum C Programming
    Replies: 4
    Last Post: 11-17-2003, 08:47 PM
  5. text line termination
    By Unregistered in forum C Programming
    Replies: 3
    Last Post: 09-09-2001, 05:39 AM

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