How can I get Single byte from 'int' type variable? Can we
alter single bit or multiple bits in int type variable? if so,
How?

Answer Posted / hassan noureddine

Use bit wise unary commands:

int i = 0x5678
char LowByte = (char) i; // yield 8;

To alter the bits

i &= 0xFF; // reset upper 2 bytes
i ^= 0xFFFF // invert all bits

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What does s c mean on snapchat?

579


Explain how can you avoid including a header more than once?

595


Explain the difference between getch() and getche() in c?

563


What is the purpose of type declarations?

673


Why void main is used in c?

559






What will be the outcome of the following conditional statement if the value of variable s is 10?

755


What is data type long in c?

621


What is #include stdio h?

679


a character or group of characters that defines a register,or a part of storage a) memory b) byte c) address d) linear list

627


What is far pointer in c?

805


What are the disadvantages of external storage class?

585


Which is the best website to learn c programming?

576


What is #ifdef ? What is its application?

642


An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above

654


Explain high-order bytes.

670