开发者

question about location of variable in memory [closed]

开发者_如何转开发 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 12 years ago.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜