Check snprintf's return value:
The snprintf() function returns the number of characters
formatted, that is, the number of characters that would have
been written to the buffer if it were large enough. If the
value of n is 0 on a call to snprintf(), an unspecified
value less than 1 is returned.

I believe the problem is here:
TOT out_string
|-- 8bytes --|----------------------- 900bytes -----------------------|
when you write to out_string probably you are running out of space and overwriting TOT. check if your output string is more than 900 chars long (return value of sprintf). btw it should overwrite _after_ or beyond the end of outstring but the compiler is allowed to place TOT after out_string which is the likely problem.
when you allocate 1500 bytes you create enough space for the entire string and your problem is solved. if you are not changing TOT throughout the prgm declare it as a const.

also, you can print addrs of TOT & out_string to see if my suggestion about compiler placing TOT after string was correct.

As jhshukla wrote, the program probably wrote beyond the bounds of the array. Neither the compiler nor the run-time system protects you from errors of this kind in C++ (or C), as part of the language's philosophy of being efficient and close to the hardware. You can protect against it by being aware of it and programming more carefully, or by using an object of a string class instead of a character array. A string object manages memory for you, so you don't have to worry about problems like this.