For the next code snippet:
char words[10][9] = {
"Hello",
"Good-bye"
};
The expression words[2][4] would give me the character 'o', but I don’t understand why.
Can anybody explain this behavior?
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.
After a “partial” initialization, all the “uninitialized” elements are effectively initialized with
0.So your element should have a value of
0(or'\0').If it hasn’t there is something else going on that you do not show us.
In C there is no partial initialization: either all elements are initialized (possibly to 0) or no elements are initialized.
See http://ideone.com/JDv86w or http://ideone.com/j6BIRP