title: Printing a right-aligned "#" staircase
body: <p>I am doing the following question in Hackerrank:<br>
  <a href="https://www.hackerrank.com/challenges/staircase?h_r=next-challenge&amp;h_v=zen" rel="nofollow noreferrer">https://www.hackerrank.com/challenges/staircase?h_r=next-challenge&amp;h_v=zen</a></p>
  
  <p>Basically, the code has to print out a right-aligned "staircase" made of "#" characters. So, if the input is 6, then the output is:</p>
  
  <pre><code>     #
      ##
     ###
    ####
   #####
  ######
  </code></pre>
  
  <p>This is the solution (in C) I have come up with:</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;string.h&gt;
  
  int main(){
      int n,i; 
      scanf("%d",&amp;n);
      char str[]="";
      for(i=0;i&lt;n;i++)
          strcat(str,"#");
      for(i=0;i&lt;n;i++)
          printf("%*.*s\n",n,i+1,str);
      return 0;
  }
  </code></pre>
  
  <p>But this is not working and I can't seem to figure out what's wrong. I am <strong><em>not looking for a new solution</em></strong>. I just want to know what my code is doing wrong.</p>
  
  <p>TIA!</p>