Replacepr(((((()))))))

Why x is not getting included in my input???
#include
using namespace std;

void replacepi(char *a,int i){
//base case
if(a[i]==’\0’ || a[i+1]==’\0’){
return;
}

//recursive case
if(a[i]=='p' and a[i+1]=='i'){
	int j = i+2;
	while(a[j]!='\0'){
		j++;
	}

	while(j>=i+2){
		a[j+2]=a[j];
		j--;
	}

	//copying the 3.14
	a[i] = '3';
	a[i+1] = '.';
	a[i+2] = '1';
	a[i+3] = '4';

	//recursion to solve for the smaller arr
	replacepi(a,i+4);
}
else{
	replacepi(a,i+1);
}

}
int main() {
int n;
cin>>n;
while(n>0){
char a[1000];
cin.get();
cin.getline(a,1000);

	replacepi(a,0);

	cout<<a<<endl;

	n--;


}


return 0;

}

hi @abhinavssr2003_eab0717682969e5c
refer this–>

#include<iostream>
using namespace std;
void solve(char ch[], int i, char out[], int j) {
	if (ch[i] == '\0') {
		cout << out << endl;
		return;
	}

	if (ch[i] == 'p' && ch[i+1] == 'i') {
		out[j] = '3';
		out[j + 1] = '.';
		out[j + 2] = '1';
		out[j + 3] = '4';
		solve(ch, i + 2, out, j + 4);
	} else {
		out[j] = ch[i];
		solve(ch, i + 1, out, j + 1);
	}
}
int main() {
	int t;
	cin >> t;
	while (t--) {
		// take input
		char ch[10000], out[10000];
		cin >> ch;

		// print output corresponding to given input
		solve(ch, 0, out, 0);
	}

	return 0;
}

please tell me the mistake in my code

hey, your corrected code–>

#include <iostream>
#include <cstring>
using namespace std;

void replace(char *a, int i)
{
    // base case
    if (a[i] == '\0' || a[i + 1] == '\0')
    {
        return;
    }

    // recursive case
    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--;
        }

        // copy the pi
        a[i] = '3';
        a[i + 1] = '.';
        a[i + 2] = '1';
        a[i + 3] = '4';

        replace(a, i + 4);
    }
    else
    {
        replace(a, i + 1);
    }
}

int main()
{

    int n;
    cin >> n;
    char a[1000];
    cin.get();
    while (n > 0)
    {
        cin.getline(a, 1000);

        replace(a, 0);

        cout << a << endl;

        n--;
    }
}

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.