+ 1
Why the output contains inrrelevent characters ?
The output contains irrelevent characters if only 0 index of array is initialised .. If index from 0-3 is initialised here then there is no abitrary characters ! https://code.sololearn.com/cRMR2D3x9GkS/?ref=app
4 ответов
+ 3
An array is allocated memory.
C does not initialise its memory automatically.
So what you see is left over data from the previous owner of that memory. Which is rubbish and a potential threat of bugs.
Especially in C always initialse the variable's you are going to use,
+ 1
Martin Taylor
Since my char array has 6 characters and I've initialised only first character then why only 2 or 3 random characters are printed instead of all the remaining 5 ?
And since I've not mentioned a null character in my char array why the printf() has stopped printing characters after those 2 or 3 garbage characters. ?