How to append 5000times of string in another string.?<>
This question is an exact duplicate of:
I am not win programmer, so I don't use this classes, but I see you wrote "sometimes it crashes". this makes me guess this is a memory issue. I would therefore try to use something like GetBufferSetLength() before starting the append, and check I did get a valid pointer. (I guess this is like reserve())
Perhaps, this line:
str1 = str1 + "\r\n";
Should be changed to:
str1 = str1 + L"\r\n";
Maybe something strange is happening with the different character widths. Otherwise, I am not sure why this program would crash.