The code for Replace All Pi is showing runtime error . Any help?

Question Link (Replace All Pi)
https://hack.codingblocks.com/practice/p/390/71

My solution
https://ide.codingblocks.com/s/48314

Hey Tushar, in ReplacePi() use else if check instead of using 2nd if check i.e if(a[index]=='p' && a[index+1]=='i')

It worked , thanks a lot