Monday, 23 May 2016

What is the size of the class when char array is declared with size 0?

 
#include<iostream>

struct structhack
{
   char a[0];
};


struct no_member_struct
{
};

int main()
{
   printf("\n  :: %u ", sizeof( structhack ) );
   printf("\n  :: %d ", sizeof( no_member_struct ) );
   return 0;
}

Output:
:: 0
:: 1