title: nice way to make a pyramid with numbers >10
body: <p>I'm new to C and programming in general. I wanted to create a pyramid of numbers I have seen on a class test. I managed to do it, but the problem is that when the numbers get over 9, the pyramid gets terrific. <a href="https://i.stack.imgur.com/impzx.jpg" rel="nofollow noreferrer">this is what I wanted to achieve without writing a lot of IFs</a></p>
  <p>my code:</p>
  <pre><code>#include &lt;stdio.h&gt;
  
  int strlen(char *str);
  
  int main(int argc, char **args){
  char spaces[] = {&quot;|                              &quot;};
  int i = 1, line = 1; //line number of numbers per line
  
  while(spaces[strlen(spaces)-1] != '|'){
  
      printf(&quot;%s&quot;, spaces);
      
      for(int k = 0; k &lt; line; k++){
          printf(&quot;%d&quot;, i);
          i++;
      }
  
      printf(&quot;\n&quot;);
      
      spaces[strlen(spaces)-1] = '\0';        
      
      line += 2;
  }
  }
  
  int strlen(char *str){
  int i = 0;
  
  while(*(str + i))
      i++;
  
  return i;
  }
  </code></pre>