title: How to Print All N-digit Numbers Recursively in C?
body: <p>I'm trying to print all N-digit numbers with a given phrase recursively (excluding 0).</p>
  <p>For example, given input:</p>
  <pre><code>void rec_fun ( &quot;Hello&quot; , 2 )
  </code></pre>
  <p>My output would be:</p>
  <pre><code>Hello 11
  Hello 12
  Hello 13
  Hello 14
  Hello 15
  ...
  Hello 21
  Hello 22
  Hello 23
  Hello 24
  ...
  Hello 96
  Hello 97
  Hello 98
  Hello 99
  </code></pre>
  <p>Some hints that I had:</p>
  <blockquote>
  <p>Use dynamic memory</p>
  </blockquote>
  <blockquote>
  <p>loop would only be used <strong>once</strong> and in the Stop condition.</p>
  </blockquote>
  <p>Given function is:</p>
  <pre><code>void rec_fun ( int char* , int num );
  </code></pre>
  <p>My try, which didn't work, but I'm posting to get some directions:</p>
  <pre><code>void rec_fun ( char* c , int num ){
      if (num == 0){
          printf(&quot;%s&quot;,c);
      }
       
      int flag = 1;
      if (num&gt;0){
          while(flag){
              for(int i=1 ; i&lt;num+1 ; i++){
                  printf(&quot;%d&quot;,i);
                  rec_fun (c, num-1);
                  printf(&quot;\n&quot;);
                  flag = 0;
              }
          }
      }
  }
  </code></pre>
  <p><strong>Would love to get some help on this !</strong></p>