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
What are identifiers in c?
Is c is a high level language?
Why main is used in c?
What are the types of operators in c?
Explain two-dimensional array.
What will the code below print when it is executed? int x = 3, y = 4; if (x = 4) y = 5; else y = 2; printf ("x=%d, y=%d ",x,y);
What are pointers? What are stacks and queues?
What is omp_num_threads?
What are the data types present in c?
What are the uses of a pointer?
What is meant by 'bit masking'?
Why can arithmetic operations not be performed on void pointers?
How do I create a directory? How do I remove a directory (and its contents)?
What are the types of assignment statements?
An arrangement of information in memory in such a way that it can be easily accessed and processed by a programming language a) string b) data structure c) pointers d) array