#include <stdio.h>
int main()
{
int a[0],b[4][0];
printf("%d %d ",sizeof(a),sizeof(b));
}
//output
0 0
what is the significance of a[0] , why also 2d array of size 0 is allowed?
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.
Neither C nor C++ allow arrays of zero length, so your program is ill-formed.
(E.g. C++11, 8.3.4/1: “[the array size] shall be greater than zero”.)
(As one point of rationale: An array of zero length would be tricky and confusing to reconcile with the requirement that each object have a unique address.)
As @sidyll points out, zero-length arrays are available as an extension in GCC.