Replace all pi recursion

#include
using namespace std;
void pireplace(char *a,int i)
{
if(a[i]==’\0’|| a[i+1]==’\0’)
return;
if(a[i]==ā€˜p’ && a[i+1]==ā€˜i’)
{
int j=i+2;
while(a[j]!=’\0’)
{
j++;
}
while(j>=i+2)
{
a[j+2]=a[j];
j–;
}
a[i]=ā€˜3’;
a[i+1]=’.’;
a[i+2]=ā€˜1’;
a[i+3]=ā€˜4’;
pireplace(a,i+4);
}

else
pireplace(a,i+1);

}
int main()
{
int n;
cin>>n;
char a[1000],c[1000];
for(int i=0;i<n;i++)
{
cin>>a[i];
}
for(int i=0;i<n;i++)
{
c[i]=a[i];
pireplace(c,0);
cout<<a[i]<<endl;
}
return 0;
}

Compilation done successfully but not clearing test cases

hi @shubhangis248 please share your code using ide.codingblocks.com

hi @shubhangis248 you are forming a character array, either form an array of strings or a 2D character array to store all the strings. Or if you want to use only a single array then you will have to run a loop n times to do so

did the same as what you told but still getting error

hi @shubhangis248 modify line 36
it should be pireplace(a[i],0);
because you are sending only 1 string at a time.

@shubhangis248 corrected code https://ide.codingblocks.com/s/335474