How does C find the size of an array at runtime? Where is the information about the array size or bounds stored ?
Share
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.
sizeof(array)is implemented entirely by the C compiler. By the time the program gets linked, what looks like asizeof()call to you has been converted into a constant.Example: when you compile this C code:
you get
The
$132in the middle is the size of the array, 132 = 4 * 33. Notice that there’s nocall sizeofinstruction – unlikeprintf, which is a real function.