I am required to write a function called bitstring, which takes a unsigned char that was created in this function:
size_t bs2n(string s)
{
assert (s.size() > 0);
if (s.size() == 1)
return s[0]-'0';
else {
string smaller = s.substr(0,s.size()-1);
return 2 * bs2n(smaller) + s[s.size()-1] - '0';
}
}
This function takes 8 bits and returns a unsigned char between 0-255
I need to be able to convert it back, but I encountered a problem when writing down the function parameters and first line from class.
What I have is:
string unsignedchar bitstring(unsigned char)
I think for one that it should be:
string unsigned char bitstring(unsigned char val)
which would make a heck of a lot more sense, but still doesn't make sense why I need the first unsigned char...
How should I write the first line of the function?