
Patrick B. answered 05/05/19
Math and computer tutor/teacher
/*******************************
declares a structure type and a union type.
then use sizeof() function to see if there is a difference of their sizes on the heap.
*********************************************/
#include <stdio.h>
typedef struct _TDataRec
{
int x;
double flAmt;
char str[25];
long longIntnum;
char boolSwitchFlag;
} * _TDataRec;
#define DATA_REC_SIZE ( (sizeof( struct _TDataRec))
typedef union _TDataNode
{
int x;
double flAmt;
char str[25];
long longIntnum;
char boolSwitchFlag;
} * _TDataNode;
#define DATA_NODE_SIZE ( (sizeof( struct _TDataNode))
int main()
{
printf(" size of data rec structure is %d \n", DATA_REC_SIZE);
printf(" size of data node union is %d \n", DATA_NODE_SIZE);
return 0;
}