Getting garbage values

In the program https://ide.codingblocks.com/s/439329
when i am entering the input it also prints garbage value. Can you please update me why is it so?

Hello @mr.nanakskhurana you are not giving any input.

I have given the input as Hello world, this is a sentence

@mr.nanakskhurana check now:


this was because in input you were getting new line very after but before that you there were some empty blocks.

okay but in the video we were told to use \0 to end the array so that we won’t get garbage values

@mr.nanakskhurana yes right but input only you have given the values so in input you are setting the null after that garbage values.

oh okay got it. Thank you

@mr.nanakskhurana if you feel that your doubt is cleared you can mark this as resolved.
Happy Learning!!

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.