I’ve the following C++ array:
byte data[] = {0xc7, 0x05, 0x04, 0x11 ,0x45, 0x00, 0x00, 0x00, 0x00, 0x00};
How can I know how many items there are in this array?
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.
For byte-sized elements, you can use
sizeof(data).More generally,
sizeof(data)/sizeof(data[0])will give the number of elements.Since this issue came up in your last question, I’ll clarify that this can’t be used when you pass an array to a function as a parameter: