Doubt for replace all pi
Hi Karthik, the error in your code is with respect to the variable k. When the recursive call takes place everytime the value of k becomes 0 at the start. i.e. whenever you write something on out string wether it be a[i] or ‘3.14’ it is always written from start i.e. 0th index. Also at last call again k=0 and when n==0 condition becomes true the function sets out[k++] i.e. out[0] to be ‘\0’ i.e. after all the processing the first charachter itself of out string becomes ‘\0’. So you need to reposition your line no. 6 i.e.:
int k = 0 ;
Think where should it be placed so that everytime the function is called the updated value of k is not lost.
Also, after this correction you will face another problem and that will be that for 1st testcase ans printed will be that of 1st testcase. For 2nd testcase it will be concatenation of ans of 1st and 2nd testcase, for 3 it will be concatenation of all 1st, 2nd and 3rd.
This will happen because of shifiting of the int k = 0 statement. And to correct it you just have to add one more statement regarding alteration of k in main itself.
Hope this helps 
Hey,
As you are not responding to this thread, I am marking your doubt as Resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “ Ask Doubt ” section, when your doubt is resolved.