Declaring a structure with no members in C language


Can we declare a structure with no members in C, if yes what will be the size of that structure?


Yes, it is allowed in C programming language that we can declare a structure without any member and in that case the size of the structure with no members will be 0 (Zero). It will be a Zero size structure.


 Live Demo

#include <stdio.h>
//structure with no members
struct temp{
int main(){
   //declaring structure variable
   struct temp T;
   printf("Size of T: %d
",sizeof(T));    return 0; }


In this C program, we are declaring a structure named "temp" without declare any variable in it, so "temp" is a structure with no members.

Then, we are declaring its variable "T" (Structure variable) and printing occupied size by "T" using sizeof() operator, and the result is "0".

Size of T: 0

Updated on: 09-Mar-2021


Kickstart Your Career

Get certified by completing the course

Get Started