How to append char to end of string in C++ || Best way to append char to end of string- There are 2 ways mention below to append char to the end of string in c++. But do you know which one is the best way? Let's see Method -1 += operator we can use += use to append char at the end of the string but by using this method it makes a copy of the initial string and take O(length of the string ) time to make a copy of a string. Method 2- Push back method by using this method we do not create any copy of original string we only put char to the and of the string so the time complexity of this function is o(1). Obviously, push back is a better method to append char at the end of the string.
Technical Keeda is best plateform for learning coding, Programming,competitive programming ,c++ language. Here we Provide best explaination of Programming question also Here You can boost your technical knowledge.You Will get aware of latest technology available in market.