Long String
I need to write about a half one page instruction string for one of my C++ programs. How do I do this best, so I can read it in the code and easly update it later. I have tried concatinating, but that makes corrections tough on the wrapping edge.
bumsfeld
Nearly a Posting Virtuoso
1,445 posts since Jul 2005
Reputation Points: 404
Solved Threads: 184
>I need to write about a half one page instruction string for one of my C++ programs.
Try again, this time in coherent English, please.
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
The way I read this, this person wants to write a string about 20 to 30 lines long. Am I correct? How to do it best within the code is not an easy question to answer.
----------------------------
I wish you were beer!
Ene Uran
Posting Virtuoso
1,723 posts since Aug 2005
Reputation Points: 625
Solved Threads: 213
I think the longest string that can be made in C or C++ is the maximum value of an integer (as defined by size_t). Compilers will concantinate string liters just by NOT using ';' between lines. Note the use of quotes below The semicolon ; only appears at the end of the string.
char big_string[] = "ljasd lakdjfl lkjdf"
"lkjsdf alkdjf"
"kjhsdfkgh kjhdfg";
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>I think the longest string that can be made in C or C++ is the maximum value of an integer (as defined by size_t).
That's a reasonable assumption, but why not just call string::max_size() and be sure?
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
>I think the longest string that can be made in C or C++ is the maximum value of an integer (as defined by size_t).
That's a reasonable assumption, but why not just call string::max_size() and be sure?
The op didn't mention using std::string class, so I assumed it was for character arrays.
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
>The op didn't mention using std::string class, so I assumed it was for character arrays.
I was getting ahead of myself again, sorry. IIRC, the minimum size of an object that the standards require is 65535 bytes, so that's the portable limit of a C-style string (including a string literal because it's an array type). Of course, implementations can extend that limit, but that's implementation-defined. And dynamically simulated arrays aren't as restricted. ;)
Narue
Bad Cop
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401