title: C++ multiplication of 2 strings representing decimal value of a number
body: <p>The idea is to overload an <code>operator *</code> so it can multiply two strings representing decimal value of a number. The operator is part of a bigger class but that is not important. The algorithm is the same as in elementary school :)</p>
  
  <p>Here's my code:</p>
  
  <pre><code>Bignumber operator* (Bignumber x, Bignumber y ){
      int i, j, transfer=0, tmp, s1, s2, k;
      char add[1];
      string sol;
      string a, b;
      Bignumber v1, v2;
      a=x.GetValue();
      b=y.GetValue();
  
      a.insert(0,"0");
      b.insert(0,"0");
  
      for(i=a.length()-1; i&gt;=0; i--){
          s1 = (int) a[i]-48;
          for(k=a.length()-i-1; k &gt;0 ; k--){
              sol+="0";
          }
          for(j=b.length()-1; j &gt;=0; j--){
              s2=(int) b[j]-48;
              tmp=s1*s2+transfer;
              if(tmp &gt;= 10){
                   transfer=tmp/10;
                   tmp=tmp-(10*transfer);
               }
              itoa(tmp, add, 10);
              sol.insert(0, add);
          }
          v1=sol;
          v2=v1+v2;
          sol.erase(0);
          transfer=0;
      }
      return v2;
  }
  </code></pre>
  
  <p>This works fine most of the time but for some random values it doesnt work properly. like for example for 128*28 it returns 4854 instead of 3584.</p>
  
  <p>Any idea what might be the problem?</p>
  
  <p><code>operator</code>s <code>+</code> and <code>=</code> are already overloaded for the class <code>Bignumber</code> and they work fine.</p>