Print longest string duplicated M times
<p>here is code  which prints longest string duplicated M times</p>

<pre><code>#include &lt;iostream&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
#include &lt;stdio.h&gt;

using namespace std;
#define M 1
#define  MAXN  5000000
char c[MAXN],*a[MAXN];
int pstrcmp( char **p,char **q){  return strcmp(*p,*q) ;}
int comlen(char *p,char *q){

    int i=0;
     while  (*p &amp;&amp;(*p++==*q++)){
         i++;
     }


      return i;


}
int main(){

    int maxlen=-1;
     int maxi; 
      int ch,n=0; 
       while ((ch=getchar())!=EOF){
           a[n]=&amp;c[n];
            c[n++]=ch;
       }
       c[n]=0;
       qsort(a,n,sizeof( char *),pstrcmp);
         for (int i=0;i&lt;n-M;i++) 
               if (comlen(a[i],a[i+M])&gt;maxlen){
                    maxlen=comlen(a[i],a[i+M]);
                    maxi=i;
               }
               printf("%.*s\n",maxlen,a[maxi]);



     return 0;
}
</code></pre>

<p>but here is mistake</p>

<pre><code>1&gt;c:\users\david\documents\visual studio 2010\projects\longest_repeted\longest_repeated.cpp(33): error C2664: 'qsort' : cannot convert parameter 4 from 'int (__cdecl *)(char **,char **)' to 'int (__cdecl *)(const void *,const void *)'
1&gt;          None of the functions with this name in scope match the target type
</code></pre>
