Replace_all_pi getting wrong output

Please check the code I am stuck like the last chars are not printing
help me where I went wrong
Thanks
(https://ide.codingblocks.com/s/480062)