#include <string.h>
#include <stdio.h>
typedef unsigned char UINT8;
struct entity { char char0; char char1; char char2; char char3; unsigned short char4;};
union name{ char _name[6]; struct entity Fname;};
struct FLAG {
UINT8 bit0 : 1;
UINT8 bit1 : 1;
UINT8 bit2 : 1;
UINT8 bit3 : 1;
UINT8 bit4 : 1;
UINT8 bit5 : 1;
UINT8 bit6 : 1;
UINT8 bit7 : 1;
};
union FLAGS { UINT8 byte; struct FLAG bit;};
union name myname;
volatile union FLAGS net_flag;
#define DEV_DIS net_flag.bit.bit0
#define ON 1
void main() {
char *test = "abcdA";
char _test[] = "abcdA";
char __test[6] = "abcdA";
printf("test strlen :%d sizeof(test) :%d sizeof(_test) :%d\n",strlen(test),sizeof(test), sizeof(_test));
printf("__test strlen :%d sizeof(test) :%d\n", strlen(__test), sizeof(__test));
strcpy_s(myname._name,sizeof(test), test);
printf("sizeof char, unsigned short, int :%d, %d, %d\n", sizeof(char),sizeof(unsigned short),sizeof(int));
printf("myname size :%d\n",sizeof(myname));
printf("myname._name size :%d\n", sizeof(myname._name));
printf("myname.Fname size :%d\n", sizeof(myname.Fname));
printf("myname.Fname include :%c %c %c %c %c\n", myname.Fname.char0, myname.Fname.char1, myname.Fname.char2, myname.Fname.char3, myname.Fname.char4);
union FLAGS flags;
flags.byte = 8;
printf(" flags 's size :%d value :%d \n",sizeof(flags.bit),flags.bit.bit2);
flags.bit.bit0 = 0;
flags.bit.bit1 = 0;
flags.bit.bit2 = 1;
flags.bit.bit3 = 1;
printf(" flags 's size :%d value :%d", sizeof(flags.bit), flags.byte);
}