Hi I am new to C programming can anyone please tell me what this line of code would do:
i = (sizeof (X) / sizeof (int))
The code actually works with a case statement when it takes a value of bdata and compares it to different cases.
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.
Generally, such a statement is used to calculate the number of elements in an array.
Let’s consider an integer array as below:
Now, when
sizeof(a)is done it will return4*4 = 16as the size. 4 elements and each element is of 4 bytes.So, when you do
sizeof(a) / sizeof(int), you will get 4 which is the length or size of the array.