Need to implement a bit_array of size 64. No external libraries except C standard ones. Need these main functions: bit_a
Posted: Sun Jul 10, 2022 11:31 am
Need to implement a bit_array of size 64.
No external libraries except C standard ones.
Need these main functions:
bit_array_allocate(int size)
bit_array_free(int position, int size)
printContents(bitArray)
EXAMPLE:
original bitmap:10111010010111100000000111111000010011010100010000000110011111000
Mallocate test cases in progress:
mem size of 1 can fit into address 0
mem size of 4 can fit into address 3
mem size of 8 can fit into address 14
USE TO PRINT BIT_ARRAY:
#include<stdio.h>
void Print_Binary(unsigned int Value);
int main(){
unsigned int x=0xF0F0F0F0; Print_Binary(x);}
void Print_Binary(unsigned int Value){ int i; unsigned int Mask = 1; Mask = Mask << 31; for(i=0; i<32; i++){ if((Mask & Value) == 0){ printf("0"); }else{ printf("1"); } Mask = Mask >> 1; } printf("\n");}
No external libraries except C standard ones.
Need these main functions:
bit_array_allocate(int size)
bit_array_free(int position, int size)
printContents(bitArray)
EXAMPLE:
original bitmap:10111010010111100000000111111000010011010100010000000110011111000
Mallocate test cases in progress:
mem size of 1 can fit into address 0
mem size of 4 can fit into address 3
mem size of 8 can fit into address 14
USE TO PRINT BIT_ARRAY:
#include<stdio.h>
void Print_Binary(unsigned int Value);
int main(){
unsigned int x=0xF0F0F0F0; Print_Binary(x);}
void Print_Binary(unsigned int Value){ int i; unsigned int Mask = 1; Mask = Mask << 31; for(i=0; i<32; i++){ if((Mask & Value) == 0){ printf("0"); }else{ printf("1"); } Mask = Mask >> 1; } printf("\n");}