we know meaning of pointers for example to get location of variable
int t=9;
we use following notation
int *p=&t;
how can i obtain address of variable in memory by bitwise operatos and bits manipulation? can i do it in general or what is equivalent of pointer in bit world?i am using c++
Using bit wise operators like and
and or
, you can't get the address of an arbitrary variable, no.
At some point, you have to use &
.
If you're talking about manipulating bits within one of the more basic types, there are (at least) two approaches you can take:
- Specify bit-field structures such as
struct { int bit:3 }
where the number after the:
is the number of bits; or - Use bitmasking tchniques like
threebits = sixteenbits & 0x07;
.
You can't get the adress via bitwise operators. You have to use the "address of" operator.
精彩评论