Quantcast
Channel: CodeChef Discuss - latest questions
Viewing all articles
Browse latest Browse all 39796

When intializing a char array, is the remaining space zero filled or uninitialized?

$
0
0

If a char array is uninitialized, are all the array elements automatically initialized as 0 ? I was solving the problem Holes and my first solution which got WA was this : http://ideone.com/Ix4kc9

I then checked someone else's solution which was almost identical but instead of for (z = 0; c[z] != '0'; ++z) , he had used for (z = 0; c[z] != '\0'; ++z) . After some googling I found that \0 is NULL character. I don't understand what it actually is. Then I found this question on SO. The top answer says that all uninitialized elements are stored as zeroes. Then why replacing for (z = 0; c[z] != '0'; ++z) with for (z = 0; c[z] != '\0'; ++z) gave me an AC?


Viewing all articles
Browse latest Browse all 39796

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>