Question: C: Create a header file named binary _ string.h . The header file should declare the following three functions: char * unsigned _ to _
C:
Create a header file named binarystring.h The header file should declare the following three functions:
char unsignedtobinaryunsigned x;
unsigned binarytounsignedchar str;
char addbinarychar str char str;
Be sure to include a header guard.
Write a C program named binarystring.c That program should implement the following three functions:
char unsignedtobinaryunsigned x
unsignedtobinary takes an unsigned number and returns a cstyle string of and characters that represents the binary representation of the argument. For example, unsignedtobinary should return a pointer to a char array containing and unsignedtobinary should return a pointer to a char array containing Notice it stores only as many "bits" as necessary you can assume a max of bits plus the null character Note: unsignedtobinary should call malloc to allocate enough space for the chars.
unsigned binarytounsignedchar str
binarytounsigned takes a pointer to a cstyle string that holds a sequence of and characters and returns the unsigned representation.
char addbinarychar str char str
addbinary takes two char cstyle binary strings and returns the sum as a binary string. You should not use the functions from the previous parts here. However, if you have helper functions that you wish to reuse, you may do so so long as they are in the spirit of what this task is asking you to do
Add the "bits" from least significant to most significant, "carrying the one" when necessary. You can again assume a max size of bits. You should discard the overflow bit if the addition exceeds this max size.
So if your helper functions say convert the entire string to numbers, add them, and turn the entire number back into one string, that does not count as solving this problem. Helper functions that do something useful in the spirit of the task like say, counting the digits of a cstyle string would be fine and even encouraged.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
