如何在C ++中更快地连接字符串?

In my code I am decoding an input and have to append each decoded part to an output string. Like output_string+= "127=" + decoded_ans; This will happen roughly 200 times. I feel the above method is not fast as it is constantly assigning more memory and what not. I know that the output_string will not go above 5000 characters. Is there a better(faster) way to this using maybe char arrays or something? Time is very important to my code.

评论