I am trying to create a long string literal, which I store inside a std::string. If I create a literal up to approximately 2600 characters, everything prints fine. If I go beyond that number of symbols, I only get some random garbage characters printed.
I have been using the C standard as guidance, environmental limits are specified as "4095 characters in a string literal (after concatenation)". But the code is written in C++.
So my question is, what is the minimum amount of characters in a C++ string literal?
(The problem might possibly be elsewhere in the code, but I would like to ensure that I don't pass a limit set by the standard. The text is printed in a RichEdit control, so I doubt that one is the culprit.)
The minimum is specified in
Annex B
Implementation quantities [implimits]
Characters in a string literal (after concatenation) [65 536].
But note that:
1) Because computers are finite, C++ implementations are inevitably limited in the size of the programs they
can successfully process. Every implementation shall document those limitations where known. This documentation
may cite fixed limits where they exist, say how to compute variable limits as a function of available
resources, or say that fixed limits do not exist or are unknown.
2) The limits may constrain quantities that include those described below or others. The bracketed number
following each quantity is recommended as the minimum for that quantity. However, these quantities are
only guidelines and do not determine compliance. (emphasis mine)
Your implementation should provide you with this number though.