Would you check whats missing in code why i am getting wrong answer for test , giving correct answer for sample input

#include
#include
using namespace std;
void ReplaceAll(char *a,char *out,int i,int j){
int temp=strlen(a);
if(i==temp){
return;
}
out[j]=a[i];
if(a[i]==‘p’ && a[i+1]==‘i’){
out[j]=‘3’;
out[++j]=’.’;
out[++j]=‘1’;
out[++j]=‘4’;
i++;
}
ReplaceAll(a,out,i+1,j+1);
}
int main(){
int n;
cin>>n;
while(n!=0){
char a[1000];
char out[1000];
cin>>a;

    ReplaceAll(a,out,0,0);
    cout<<out<<endl;
 
    n--;
}
return 0;

}

Hello @Himanshu0123

Run your code for the following testcase:
3
xabpixx3.15x
xpix
xpipippixx
Expected Output:
xab3.14xx3.15x
x3.14x
x3.143.14p3.14xx

Hope, this would help.
Give a like, if you are satisfied.

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.