title: Convert int to binary string of certain size
body: <p>I'm struggling to adapt to C after programming in Java for some time and I need help. What I'm looking for is a method that takes following input:</p>
  
  <ol>
  <li>Integer <code>n</code>, the one to be converted to binary string (character array).</li>
  <li><p>Integer <code>length</code>, which defines the length of the string (positions from the left not filled with the binary numbers are going to be set to default 0).</p>
  
  <pre><code>//Here's some quick code in Java to get a better understanding of what I'm looking for:
  
  public static String convertToBinary(int length, int n) {
    return String.format("%1$" + bit + "s", Integer.toBinaryString(value)).replace(' ', '0');
  }
  
  System.out.println(convertToBinary(8,1));
  
  // OUTPUT:
  
  00000001 (not just 1 or 01)
  </code></pre></li>
  </ol>
  
  <p>Any hints on what the equivalent of this would be in C? Also, could you provide me with an example of how the resulting binary string should be returned?</p>
  
  <p><em>(not a duplicate, since what I'm looking for is '00000001', not simply '1')</em></p>