Replace all pi Problem

My code shows different output. Please tell me how should i correct it.

Instead of making changes to the same character array, declare another new array and keep adding characters to it accordingly. I would suggest you to use strings rather than character arrays, as strings are easier to work with.

So i use string now and my code works perfectly fine on CB id but while submiting it shows this error runguard: warning: timelimit exceeded (wall time): aborting command runguard: warning: command terminated with signal 15 My code: https://ide.codingblocks.com/s/325147 How should i remove this.

Take an auxiliary output string and pass it by reference to your function. Add characters accordingly to it. When i==s.size(), simply display the new string.

Don’t make changes to your original string.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.