In this sorta of example i just wanted to know how to assign a whole number when you split up the int into a b c but if i know the whole unsigned int could i just assign it withoutCode:#include<stdio.h>
#include<stdlib.h>
struct foo
{
unsigned int a:16;
unsigned int b:8;
unsigned int c:4;
} *fooptr = NULL;
int main( void )
{
if( (fooptr = malloc( sizeof *fooptr )) == NULL )
printf( "malloc failed, that's bad\n" );
else
{
fooptr->a = 1;
fooptr->b = 2;
fooptr->c = 3;
free( fooptr );
}
return 0;
}
fooptr->a = 1;
fooptr->b = 2;
fooptr->c = 3;