title: Converting a Numerical String to an Array of Bytes Represented in Binary
body: <p>I’d like to convert a string containing only integers to an array of bytes, but to be stored efficiently (so no “digits[digitIndex] = string[digitIndex - ‘0’;”). I would like them to be stored like any type is stored: having 256 different possibilities per byte, not only 10 as in the previous, faulty example. It also needs to hold a lot of digits (I’m using an 8-bit parameter as the size, so at least 100 digits I believe). Edit: I also do not want to use any libraries whatsoever for personal reasons.</p>
  
  <p>Here’s an example of what it would look like in a function:</p>
  
  <pre><code>int8_t *stringToBigInt(char *input) {
      uint8_t digitsBase10 = strlen(input);
      uint8_t bytes = ???; //However many bytes to store the result (max 255 bytes in this case)
      int8_t *result = malloc(sizeof(void *) + bytes);
      ... //Code for setting result to input
      return result;
  }
  </code></pre>
  
  <p>And here’s an example of a possible input and output:</p>
  
  <p>Edit: This is a short example that fits into 32-bits only for simplicity; an input could be much more than a 32-bit (and possibly 64-bit) integer</p>
  
  <p>Input: “1234567890”</p>
  
  <p>Output: {01001001, 10010110, 00000010, 11010010}</p>