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.

>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.

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!

The answer to such a question depends highly on what type of application you are making and what your preferences are.

If it is a large, multi-file program, you can have a text file that holds strings that are used in different parts of the program. This way you can update the text without recompiling the code.

If you want the text in the program code itself, I'd have it as one large string on one line, this way you can easily copy all the text, paste it in Notepad, modify the text there, and paste it back in the code without the hassle of handling multiple lines in the code.

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";

>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?

>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.

>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. ;)

This article has been dead for over six months. Start a new discussion instead.