Get the size of a struct : Struct Size « Structure « C / ANSI-C






Get the size of a struct

#include <stdio.h>

struct struct_type {
  int i;
  char ch;
  int *p;
  double d;
} s;

int main(void)
{
  printf("s_type is %d bytes long", sizeof(struct struct_type));

  return 0;
}


           
       








Related examples in the same category

1.Allocate memory for struct