title: Inserting 'n' tabs in printf statement
body: <p>I'm trying to understand recursion and backtracking with standard string permutation algorithm <code>(swap --&gt; permute --&gt; swap)</code></p>
  
  <p>Since I can't seem to get my head around how it backtracks, swaps the characters and permutes, I've tried to insert printfs at every recursive permute() call with incrementing indentation "levels". Anyway here's the code:</p>
  
  <pre><code>void permute(char arr[], int L, int R, int level)
  {
      int i = 0;
      level = level+1;
  
      if(L == R)
      {
          printf("%*s", level, "\t");
          printf("printing : %s\n", arr);
      }
      else
      {
          for(i = L; i &lt;= R; i++)
          {
              printf("%*s", level, "\t");
              printf("swapping %c with %c\n", arr[L], arr[i]);
              SWAP(&amp;arr[L], &amp;arr[i]);
  
              permute(arr, L+1, R, level);
  
              printf("%*s", level, "\t");
              printf("swapping back %c with %c\n", arr[i], arr[L]);
              SWAP(&amp;arr[L], &amp;arr[i]);
          }
      }
  }
  int main()
  {
      char str[] = "abc";
      permute(str, 0, 2, 0);
      return 0;
  }
  </code></pre>
  
  <p>What I want is <code>printf("%*s", level, "\t");</code> to put incrementing tabs as we go into deeper recursive levels. But that isn't working and I'm getting a block of text shifted by one tab.</p>
  
  <pre><code>swapping a with a
  swapping b with b
  printing : abc
  swapping back b with b
  swapping b with c
  printing : acb
  swapping back b with c
  swapping back a with a
  swapping a with b
  swapping a with a
  printing : bac
  swapping back a with a
  swapping a with c
  printing : bca
  swapping back a with c
  swapping back a with b
  swapping a with c
  swapping b with b
  printing : cba
  swapping back b with b
  swapping b with a
  printing : cab
  swapping back b with a
  swapping back a with c
  </code></pre>
  
  <p>Any idea how to get printf to insert <code>(level * '\t')</code> tabs?</p>