字节数计算

typedef struct _input_key
{
  u8 input_buf[24];
  u8 input_times;
} input_key_type;

input_key_type inputkey_tmp_2;
static u8 len = 0;
len = sizeof(input_key_type);  // 25bytes

static u8 len1 = 0;
len1 = sizeof(inputkey_tmp_2);  // 25bytes

static u8 len2 = 0;
len2 = sizeof(u8);  // len2 = 1

static u8 len3 = 0;
static u8 len4 = 0;
u8 arr8[5];
u16 arr16[12];

len3 = sizeof(arr8);  // len3 = 5
len4 = sizeof(arr16); // len4 = 24

猜你喜欢

转载自www.cnblogs.com/nxz-diy/p/10024439.html