Results 1 to 6 of 6

Thread: #define a string in multiple lines?

  1. #1
    l33t! MrPolite's Avatar
    Join Date
    Sep 01
    Posts
    4,428

    #define a string in multiple lines?

    I hope there's an easy way to do this. I have a long string spanning multiple lines. I just want to write that to a file in a function. I'm wondering if there is a way to make a #define that lets the string span multiple lines?
    Or is there a better approach to this? There's a whole bunch of invalid characters in it too and it's a pain to remove them one by one.
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 01
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: #define a string in multiple lines?

    If your line ends with an underscore, it will be carried over to the next line. I'm not sure if this will work inside a string constant, but it's worth a shot!

    Code:
    #define foo()   this is a; _
       multiple line; _
       definition;
    Edit: wrong character. Use the backslash (\) instead.
    Last edited by sunburnt; May 12th, 2006 at 11:47 AM.
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  3. #3
    l33t! MrPolite's Avatar
    Join Date
    Sep 01
    Posts
    4,428

    Re: #define a string in multiple lines?

    aah my friend just showed me to use \ at the end
    what's the difference between usign that and _
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  4. #4
    Kitten CornedBee's Avatar
    Join Date
    Aug 01
    Location
    In a microchip!
    Posts
    11,594

    Re: #define a string in multiple lines?

    The _ is the VB way, and sunburnt either made a typo or confused the two. It won't work in C++, at least not standard C++.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  5. #5
    PowerPoster sunburnt's Avatar
    Join Date
    Feb 01
    Location
    Boulder, Colorado
    Posts
    1,403

    Re: #define a string in multiple lines?

    Quote Originally Posted by CornedBee
    The _ is the VB way, and sunburnt either made a typo or confused the two. It won't work in C++, at least not standard C++.

    Whoops, you're right -- teaches me to post late at night I meant to use the backslash character!
    Every passing hour brings the Solar System forty-three thousand miles closer to Globular Cluster M13 in Hercules -- and still there are some misfits who insist that there is no such thing as progress.

  6. #6
    l33t! MrPolite's Avatar
    Join Date
    Sep 01
    Posts
    4,428

    Re: #define a string in multiple lines?

    hehe
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •