Q:

How to manipulate structure members using bitwise operations?

For example, for a structure:
struct name{
 int a;
 char b;
 float c;
}g;
g.b='X';

Now I would like to access structure member b using bitwise operators(<<,>> etc.) and change it to 'A'.
Is it possible to access structure members using such operators??

A:

Bitwise operations on struct's doesn't make to much sense because of padding and  more importantly it's just killing the purpose of having a struct in the first place. Bitwise operation are as the name said to operate on bit's in variable. Struct variables usually (if they're not packed) will be padded so until you pack them you wouldn't have guarantee where they are to access them but if you want to ask if you can, yes you can, but you would have to cast struct g to let's say 32 bit value then if two variables would be in this space you could use bit operation on this casted value. If it's necessary you can create union from your struct and have raw variable as one union part, and structure as the other option, then you can manipulate bitwise on raw variable.

