You will have to create a second buffer to copy the changed string. Making single character changes is easy because the length of the result is exactly the same as the input. There is a small chance that will happen with random replacement strings, but you can't trust that will happen. You will want to create your buffer for the replacement at least as long as the maximum possible length. This is far from impossible, but does intail alot of bookkeeping which is why so many libraries exist for that sort of thing. Also, don't forget to deallocate your buffer once you are done with it, else you will have a resource leak that could take a long time to track down.