I am getting the correct replacement however why is the last character missing from all the strings

#include
#include
using namespace std;

string format(string s,int i,string &o){

if(s[i+1]=='\0')
	return o;
if(s[i]=='p'&&s[i+1]=='i')
{	o+="3.14";
    return format(s,i+2,o);
}
	else
{	o+=s[i];
return format(s,i+1,o);}

}

int main() {

int n;
cin>>n;

while(n-->0)
{string s,o;
cin>>s;
cout<<format(s,0,o)<<endl;}

return 0;

}

@amangupta please share your code by saving it on cb ide

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.