32bit to 4bytes(4*8bits)?
-
Hi,All In my application, i have to convert 32bit number to 4bytes(i.e each byte having 8bits). can any one help me.. thanks in advance regrads :rose: anju
int x = 0x01020304 ;
const unsigned char* p = (unsigned char*) &x ;
for ( int i=0 ; i < 4 ; ++i )
cout << p[i] << endl ;
You should save yourself and your company years of grief by shooting yourself through the head immediately. Believe me, in the long run it'll turn out better for everyone. - Tyto (at arstechnica) Awasu 1.0[^]: A free RSS reader with support for Code Project.
-
Hi,All In my application, i have to convert 32bit number to 4bytes(i.e each byte having 8bits). can any one help me.. thanks in advance regrads :rose: anju
unsigned int i = 0x11223344;
BYTE *pb = (BYTE *)&i;
TRACE("%d, %d, %d, %d", pb[0], pb[1], pb[2], pb[3]);
When history comes, it always takes you by surprise.
-
Hi,All In my application, i have to convert 32bit number to 4bytes(i.e each byte having 8bits). can any one help me.. thanks in advance regrads :rose: anju
int x = 0xfc12a15d;
char c[4];
for (int y = 0; y < 4; ++y)
c[y] = (x & (0xff << (y * 8))) >> (y * 8);
[
](http://www.canucks.com)Sonork 100.11743 Chicken Little "You're obviously a superstar." - Christian Graus about me - 12 Feb '03 Within you lies the power for good - Use it!
-
Hi,All In my application, i have to convert 32bit number to 4bytes(i.e each byte having 8bits). can any one help me.. thanks in advance regrads :rose: anju