Doubt in replace pi with 3.14 question

this code is showing wrong answer when i compute size of array after calling the replcepi function and if i comment out the both the lines of computing and printing out size off the array, then it is giving correct answer…why is it so?

hello @we_kaash

the issue is not with the computing or printing size.
instead the issue is in the array size , since u have not mentioned the size , the compiler will take its size equal to its content (it initilaised with).

and when u try to add some extra character in it at the time of replacepi function , it will give segmentation fault becuase the array has no more space.
to fix it declare a bit large size array by explicitly mentioning the size.
check ur corrected code here->

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.