title: Return all codes - String
body: <p>Assume that the value of a = 1, b = 2, c = 3, ... , z = 26. You are given a numeric string S. Write a program to return the list of all possible codes that can be generated from the given string.</p>
  
  <p>For most of the cases this code works but it gives wrong output for inputs which have numbers greater than 26. For eg: 12345.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string.h&gt;
  using namespace std;
  
  
  using namespace std;
  int atoi(char a)
  {
      int i=a-'0';
      return i;
  }
  char itoa(int i)
  {
      char c='a'+i-1;
      return c;
  }
  int getCodes(string input, string output[10000]) {
     if(input.size()==0)
     {
         return 1;
     }
      if(input.size()==1)
      {
          output[0]=output[0]+itoa(atoi(input[0]));
          return 1;
      }
      string result1[10000],result2[10000];
      int size2;
  
      int size1=getCodes(input.substr(1),result1);
      if(input.size()&gt;1)
      {
          if(atoi(input[0])*10+atoi(input[1])&gt;10&amp;&amp;atoi(input[0])*10+atoi(input[1])&lt;27)
          {
              size2=getCodes(input.substr(2),result2);
          }
  
      }
      for(int i=0;i&lt;size1;i++)
      {
          output[i]=itoa(atoi(input[0]))+result1[i];
      }
      for(int i=0;i&lt;size2;i++)
      {
          output[i+size1]=itoa(atoi(input[0])*10+atoi(input[1]))+result2[i];
      }
      return size1+size2;
  }
  
  
  
  int main(){
      string input;
      cin &gt;&gt; input;
  
      string output[10000];
      int count = getCodes(input, output);
      for(int i = 0; i &lt; count &amp;&amp; i &lt; 10000; i++)
          cout &lt;&lt; output[i] &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>if i give input 12345, the output is:
  "
  abcde
  awde
  lcde
  l"
  instead of :
  "
  abcde
  awde
  lcde"</p>