unable to pass values to struct as a byte.
Hi,
I am using a struct and tying to send values to it as byte value
Code:
#include<stdio.h>
typedef struct{
unsigned r1:1;
unsigned r2:1;
unsigned r3:1;
unsigned r4:1;
unsigned r5:1;
unsigned dummy:3; // empty port
}rangeflags;
rangeflags Range;
int main()
{
Range.r1 = 1;
printf("%d%d%d%d%d\n",Range.r1,Range.r2,Range.r3,Range.r4,Range.r5);
Range = 0b00100000;
//Range = 0x20;
printf("%d%d%d%d%d\n",Range.r1,Range.r2,Range.r3,Range.r4,Range.r5);
}
Error:
error: invalid suffix "b00100000" or incompatible types in assignment
I am able to access the member as Range.r1 = 1; and have no problems.
I want to send data whole at once, but how ?