Print bit values in a byte
Recently I have been working on interesting piece of code whose crux is create a array of pointer addresses.
Each entry in this array is address pointing to memory location.
For example
Container array contains char addresses. Here, 100 is memory address where char value resides.
---------------------------
| 100 | 1000 | 2000|
----------------------------
Address 100
--------------------------------
| v | a | i | b | h | a | v |
--------------------------------
Sometimes char data types is used as a package of 8 bits not as a valid char value.
Here is a code snippet
Focusing on following code section
In this section, a memory of 10 chars is being allocated, initialized and finally assigned to container array.
Lets observer, if we have set the right information in each char bit.
Compile code using
For example
Container array contains char addresses. Here, 100 is memory address where char value resides.
---------------------------
| 100 | 1000 | 2000|
----------------------------
Address 100
--------------------------------
| v | a | i | b | h | a | v |
--------------------------------
Sometimes char data types is used as a package of 8 bits not as a valid char value.
Here is a code snippet
Focusing on following code section
In this section, a memory of 10 chars is being allocated, initialized and finally assigned to container array.
Lets observer, if we have set the right information in each char bit.
Compile code using
gcc -g fileName.c
No comments:
Post a Comment