4

i have a big problem and i dont know how to fix it...

I want to decode a very long Base64 encoded string (980.000 Chars) but every time when i to debug it i get this error :

Error C2026: string too big, trailing characters truntraced

I tried this but i can only compare 2 strings throught this method

char* toHash1 = "LONG BASE 64 Code";
char* toHash2 = "LONG BASE 64 Code";

if (true) {
  sprintf_s(output, outputSize, "%s", base64_decode(toHash1 =+ toHash2).c_str());
}

Anyone know how i can get it to work?

Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
Dieter
  • 41
  • 1
  • 2

2 Answers2

4

As documented here, you can only have about 2048 characters in a string literal when using MSVC. You can get up to 65535 characters by concatenation, but since this is still too short, you cannot use string literals here.

One solution would be reading the string from a file into some allocated char buffer. I do not know of any such limits for gcc and clang, so trying to use them instead of MSVC could solve this too.

Baum mit Augen
  • 49,044
  • 25
  • 144
  • 182
  • As of late 2022 the limit on total characters that may be concatenated in Visual Studio has been greatly increased, if not eliminated. The string literal size constraint still exists (64kB) (see [here](https://learn.microsoft.com/en-us/cpp/cpp/string-and-character-literals-cpp?view=msvc-170)). I was able to use concatenation to initialize a string of over 3MB before the compiler generated an error (fatal error C1060: compiler is out of heap space) – Jeff Leonard Dec 31 '22 at 04:46
3

You can first convert your string to hex and then can include it like this,

char data[] = {0xde,0xad,0xbe,0xef};  //example

And than can use it like a string, append null terminator if needed to.

Alok Saini
  • 321
  • 7
  • 18