Immortal said:
How many characters are limited on either char* and string? The
maximum 256 characters should be sufficient.
Sufficient for what use?
You might say that you
want to write unlimited characters like 512 or 1,024 characters if you
include new line ‘\n’.
You might want more. It depends what kind of information you're
storing. Not everyone wants to write out the data they're storing in a
char[] or std::string.
Do you think that maximum 256 characters is best practice in C++
Standard Library?
No. I don't think this is a limit in the standard. 256 characters seems
like an unreasonably low limitation. I suspect that you are asking about
code written to process text a line at a time, so it may not be exactly
what you're looking for but Appendix B of the last draft I have has
these limits on source code,
- Characters in one logical source line [65 536].
— Characters in a character string literal or wide string literal (after
concatenation) [65 536].
— Size of an object [262 144].
These seem far more reasonable to me than 256.
If you are writing text processing software 256 is a limit that will
probably come back to hurt you at some point. And any limit may be
problematic at some point. You should consider that it's possible on
many systems for a user to store a line of text on mass storage that is
larger than available memory.
LR