title: Most efficient way to store an unsigned 16-bit Integer to a file
body: <p>I'm making a dictionary compressor in C with dictionary max size 64000. Because of this, I'm storing my entries as 16-bit integers. </p>
  
  <p><strong>What I'm currently doing:</strong>
   To encode 'a', I get its ASCII value, 97, and then convert this number into a string representation of the 16-bit integer of 97. So I end up encoding '0000000001100001' for 'a', which obviously isn't saving much space in the short run.</p>
  
  <p>I'm aware that more efficient versions of this algorithm would start with smaller integer sizes (less bits of storage until we need more), but I'm wondering if there's a better way to either</p>
  
  <ol>
  <li><p>Convert my integer '97' into an ASCII string of fixed length that can store 16 bits of data (97 would be x digits, 46347 would also be x digits)</p></li>
  <li><p>writing to a file that can ONLY store 1s and 0s. Because as it is, it seems like I'm writing 16 ascii characters to a text file, each of which is 8 bits...so that's not really helping the cause much, is it?</p></li>
  </ol>
  
  <p>Please let me know if I can be more clear in any way. I'm pretty new to this site. Thank you!</p>
  
  <p>EDIT: How I store my dictionary is entirely up to me as far as I know. I just know that I need to be able to easily read the encoded file back and get the integers from it. </p>
  
  <p>Also, I can <strong>only</strong> include stdio.h, stdlib.h, string.h, and header files I wrote for the program.</p>