title: mergesort algorithm in c++
body: <p>i have following code</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  void merge(int c[],int a[],int n,int b[],int m){
           for (int i=0,j=0,k=0;k&lt;n+m;k++){
  
               if (i==n) {  c[k]=b[j++]; continue;}
               if (j==m ){  c[k]=a[i++];continue;}
  
               c[k]=(a[i]&lt;b[j])? a[i++]:b[j++];
  
           }
  
  
  
  }
  void mergesort(int a[],int b[],int l,int r){
  if (l&gt;r)  return ;
       int m=(l+r)/2;
  
       mergesort(b,a,l,m);
       mergesort(b,a,m+1,r);
  
   merge(a+l,b+l,m-l+1,b+m+1,r-m);
  
  }
  int main(){
  
  
      int a[]={12,4,2,5,3,6,7,8,10,11};
  const   int n=sizeof(a)/sizeof(int);
  int b[n];
  mergesort(a,b,0,n-1);
      for (int i=0;i&lt;n;i++){
  
          cout&lt;&lt;b[i]&lt;&lt; "  ";
  
      }
  
  
  
  
       return 0;
  }
  </code></pre>
  
  <p>but here is such warning</p>
  
  <pre><code>1&gt;------ Rebuild All started: Project: mergesort, Configuration: Debug Win32 ------
  1&gt;  mergesort.cpp
  1&gt;d:\c++_algorithms\mergesort\mergesort\mergesort.cpp(24): warning C4717: 'mergesort' : recursive on all control paths, function will cause runtime stack overflow
  1&gt;  mergesort.vcxproj -&gt; D:\c++_algorithms\mergesort\Debug\mergesort.exe
  ========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
  </code></pre>
  
  <p>please help me to fix it</p>
  
  <p>i have updated my code</p>