Pages

Saturday, March 29, 2014

C Program to calculate the memory allocated by structure and union

/*memory allocate by the union and structure*/
#include <stdio.h>
#include<stdlib.h>
struct
{
      float f;
      int i;
      char c;
}s;
union
{
      float f;
      int i;
      char c;
}u;
int main()
{
    printf("memory allocate by structure=%d",sizeof(s));
    printf("\n memory allocate by union=%d",sizeof(u));
    system("pause");
    return 0;
}

No comments:

Post a Comment