Consider the following char array:
char str[128] = "abcd";
Are all the remaining uninitialized chars in the rest of the array (from str[4] to str[127]) zero/null filled?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, if there are fewer elements explicitly given in an initialiser than the aggregate contains, then the remaining elements are initialised as if the aggregate had static storage duration. For integer types (and
charis one) that means with 0s.The relevant section of the standard is 6.7.9 (21):
String literals as initialisers for
chararrays are equivalent to brace-encloded initialisers in that respect.