title: printf right align a bracketed number
body: <p>I'm writing a program that displays all the info in an array. It has to start with the array index in brackets (e.g. <code>[2]</code>) and they have to be right aligned with each other.</p>
  
  <p>if it was just the number, I know that you can do:</p>
  
  <pre><code>printf("%-10d", index);
  </code></pre>
  
  <p>but putting brackets around that would give the following output</p>
  
  <pre><code>[         1]
  [         2]
  ...
  [        10]
  [        11]
  </code></pre>
  
  <p>when I really want it to be:</p>
  
  <pre><code>         [1]
           [2]
  ...
          [10]
          [11]
  </code></pre>
  
  <p>How do I go about doing this?</p>