title: Rewriting C++ template for C
body: <p>Can anyone help me in rewriting this code from C++ to C... (it has templates... yeeee :))
  Thank you.</p>
  
  <pre><code>template &lt;class T&gt;
  void SWAP( T&amp; t1, T&amp; t2 ) 
    { 
      T tmp=t1; 
    t1=t2;
      t2=tmp;
    }
  </code></pre>
  
  <p>and this one</p>
  
  <pre><code>template &lt;class CMP, class Element&gt;
  void sh_qsort( Element* array, uint lo, uint hi )
    {
      some code...
    }
  </code></pre>
  
  <p>and the sh_qsort is called like <code>sh_qsort&lt;TEST&gt;( test_file, 0, 255 )</code>
  where <code>TEST</code> is</p>
  
  <pre><code>struct TEST {
  
  static int  c( uint* A, int x, int y ) 
  {
    uint px = A[x];
    uint py = A[y];
    int r,s;
    s = (px&lt;py) ? SWAP(px,py),0x80000000 : 0;
    byte* p = &amp;f_buf[px]; 
    byte* th = &amp;f_buf[blocksize];
    byte* q = &amp;f_buf[py];
    for(; (r=1,p&lt;th) &amp;&amp; ((r=(*p)-(*q))==0); p++,q++ );
    return r^s;
  }
  
  static void s( uint* A, int x, int y )
    {
      SWAP( A[x], A[y] );
    }
  };
  </code></pre>
  
  <p>and how to rewrite this struct in c.</p>
  
  <p>Simple and neat... HELP :)</p>
  
  <p>Thank you!</p>