Thread: Multiline strings

  1. #1
    Registered User
    Join Date
    Sep 2006
    Posts
    55

    Multiline strings

    I am writing a curses program and was wondering if it is possible to declare a multiline string constant like the following:

    Code:
    #define GRID"                                 |	                |
    						         |		    |
    						         |		    |
                                                             |		    |
                                             ----------- + ----------- + -----------   "
    Thanks.

  2. #2
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    A macro can be several lines if you add a \ at the end of each line.
    This isn't exactly a string, though.
    For const char, you can do

    const char str[] = "something"
    "something2"
    "something3";

    And so on.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,318
    Kinda like this?:
    Code:
    #define GRID \
    "             |           |             \n" \
    "             |           |             \n" \
    "             |           |             \n" \
    "   --------- + --------- + ---------   \n" \
    "             |           |             \n" \
    "             |           |             \n" \
    "             |           |             \n" \
    "   --------- + --------- + ---------   \n" \
    "             |           |             \n" \
    "             |           |             \n" \
    "             |           |             \n"
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

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. Problems with strings as key in STL maps
    By all_names_taken in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:34 AM
  4. Reading strings input by the user...
    By Cmuppet in forum C Programming
    Replies: 13
    Last Post: 07-21-2004, 06:37 AM
  5. menus and strings
    By garycastillo in forum C Programming
    Replies: 3
    Last Post: 04-29-2002, 11:23 AM