typedef struct {
unsigned char a,
unsigned char b,
unsigned char c
}type_a;
typedef struct {
unsigned char e,
unsigned char f[2]
}type_b;
type_a sample;
sample.a = 1;
sample.b = 2;
sample.c = 3;
How do I typecast it and assign new value like:
sample = (type_b)sample; // syntax error
sample.f[1] = 'a';
You can’t cast one data type to another incompatible data type. However, the memory is open for you. You can access it as follows:
Try out yourself accessing
sample_b->eandsample_b->fand see what happens.