2

The max string size is 65535 bytes according to this and other SO posts:

https://learn.microsoft.com/en-us/cpp/c-language/maximum-string-length?view=msvc-160

I have been trying to google working around such as splitting strings into several and then joining them or using define.

If I download the base64 string or read it from a file it works fine even though that still ends up being a std::string = readfromfile etc.

I am sure this topic has been touched on many times but I cannot find a definite answer on workarounds. I am assuming there are ones for such a popular mainstream language to not be held back by a somewhat arbitrary number.

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • 1
    I doubt that’s a limit of std::string – Daniel A. White Jan 22 '22 at 02:49
  • 11
    it's a limit of a single **string literal** in the source code and has nothing to do with string length – phuclv Jan 22 '22 at 02:51
  • Further, that’s the maximum that Microsoft’s compiler can handle. Other compilers are probably different. – Pete Becker Jan 22 '22 at 02:56
  • 1
    I've used `std::string` in Visual Studio to hold multiple megabytes of data. That shouldn't be your issue. – Retired Ninja Jan 22 '22 at 02:56
  • Does this answer your question? [Visual C++ and extremely long strings](https://stackoverflow.com/questions/30341683/visual-c-and-extremely-long-strings) – phuclv Jan 22 '22 at 03:01
  • The Microsoft link is not correct. Neither C nor C++ adds an extra byte to each concatinated line. Just a null byte at the end of all the concatinated lines. – doug Jan 22 '22 at 03:06
  • [Increase string literal length limit](https://stackoverflow.com/q/45275732/995714) – phuclv Jan 22 '22 at 03:17
  • *The max string size is 65535 bytes according to this and other SO posts:* -- Well, if you had just written your program totally not knowing anything about that link you found, your program would have worked -- a mild version of [analysis paralysis](https://en.wikipedia.org/wiki/Analysis_paralysis). *If* for some reason your `std::string` couldn't hold more than 65535 characters, then it would have made sense to start searching for answers. – PaulMcKenzie Jan 22 '22 at 03:59
  • I'm curious what you mean by "using define" – Nathan Pierson Jan 22 '22 at 04:12
  • Please show a [mre] of the code you are having a problem with – Alan Birtles Jan 22 '22 at 08:07

0 Answers0