Hi everyone, I have a program with bit field. However, it displays error when I try to compile. Please show me why it displays error. Thank you so much.
#include <stdio.h>
#include <stdlib.h>
typedef struct
{
unsigned b1:1;
unsigned b2:1;
unsigned b3:1;
unsigned b4:1;
unsigned b5:1;
unsigned b6:1;
unsigned b7:1;
unsigned b8:1;
} byte_s;
int main(void) {
byte_s bfbyte;
unsigned char a[]={0x11,0xff};
bfbyte= (byte_s) a[0]; //displays error: conversion to non-scalar type requested
printf ("%d %d %d %d : %d %d %d %d \n",
bfbyte.b1, bfbyte.b2, bfbyte.b3, bfbyte.b4,
bfbyte.b5, bfbyte.b6, bfbyte.b7, bfbyte.b8);
printf ("%d %d %d %d : %d %d %d %d \n",
bfbyte.b1, bfbyte.b2, bfbyte.b3, bfbyte.b4,
bfbyte.b5, bfbyte.b6, bfbyte.b7, bfbyte.b8);
return EXIT_SUCCESS;
}