title: Having a hard time creating a function that displays all different combinations of n numbers (0<n<10)by ascending order
body: <p>I'm having difficulty finding the underlying logic for this. I know recursion would help however I don't know how to approach it. My difficulty lies when get dealing with sending/ printing the array on the base case. Everything I do I can only iterate the last digit and don't know how to go about the others.</p>
  <p>If n is 2:</p>
  <p><code>$&gt;./a.out | cat -e</code></p>
  <p><code>01, 02, 03, ..., 09, 12, ..., 79, 89$</code></p>
  <p>If n is 3  things get harder:</p>
  <p><code>012, 013, 014, ..., 123, 124, ..., 134, 135,... 234, ..., 789$</code></p>
  <p>My code is far from working</p>
  <pre><code>#include &lt;unistd.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;stdbool.h&gt;
  
  void    ft_putchar(char c)
  {
      write(1, &amp;c, 1);
  }
  
  bool is_consecutive(int arr[], int n)
  {
      int last_value = 9;
      if ( n &lt;= 0 )
          return false;
      while ( --n ) {
          if ( arr[n] != last_value-- )
              return false;
      }
      return true;
  }
  
  void    ft_print_screen(int *t, int size)
  {
          int i;
      
      i = 0;
          while (i &lt; size)
      {
                  ft_putchar(t[i] + '0');
          i++;
      }
          if (is_consecutive(t, size) != true)
          {
              ft_putchar(',');
              ft_putchar(' ');
          }
  }
  
  void    ft_print_combn(int n)
  {
          int i;
          int tab[n];
  
          i = 0;
          if (n == 1)
                  while (i &lt; 10)
          {
                          ft_putchar(i + '0');
              i++;
          }
          while (i &lt; n)
      {
                  tab[i] = 0;
          i++;
      }
          while (tab[0] &lt;= (10 - n) &amp;&amp; n &gt; 1)
          {
                  ft_print_screen(tab, n);
                  tab[n - 1]++;
                  i = n;
                  while (i &amp;&amp; n &gt; 1)
                  {
                          i--;
                          if (tab[i] &gt; 9)
                          {
                                  tab[i - 1]++;
                                  tab[i] = 0;
                          }
                  }
          }
  }
  
  void main(int argc, char *argv[])
  {
      int x = atoi(argv[1]);
      ft_print_combn(x);
  }
  </code></pre>