最长重复子串

场景:最长重复子串有关问题

最长重复子串问题
求大神指点
想要把一个字符串中重复最长的部分提取出来,比如说有如下字符串:
abcdbcdbcb
对于这个字符串最长的重复子串为bcdbc!

查了下网上的解答,代码如下
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
 
#define MAXCHAR 5000 //最长处理5000个字符
 
char c[MAXCHAR], *a[MAXCHAR];
 
int comlen( char *p, char *q ){
    int i = 0;
    while( *p && (*p++ == *q++) )
        ++i;
    return i;
}
 
int pstrcmp( const void *p1, const void *p2 ){    // 这个函数是什么意思,参数看不懂
    return strcmp( *(char* const *)p1, *(char* const*)p2 );
}
 
int main(  ){
    char ch;
    int  n=0;
    int  i, temp;
    int  maxlen=0, maxi=0;
    printf("Please input your string:\n");
    while( (ch=getchar())!='\n' ){
        a[n]=&c[n];
        c[n++]=ch;
    }
    c[n]='\0';
    qsort( a, n, sizeof(char*), pstrcmp );   // 这里的快速排序是对什么排序
    for(i=0; i<n-1; ++i ){
        temp=comlen( a[i], a[i+1] );
        if( temp>maxlen ){
            maxlen=temp;
            maxi=i;
        }
    }
    printf("%.*s\n",maxlen, a[maxi]);
    system("PAUSE");
    return 0;
}

但是这个代码看不懂,求大神指点

------解决方案--------------------
int pstrcmp( const void *p1, const void *p2 ){//该函数是qsort函数的“回调”函数。两个参数的类型为指向常量的无类型指针
    return strcmp( *(char* const *)p1, *(char* const*)p2 );//将参数强制类型转换为char* const *类型,然后取其值,其值为char* const类型。
}
------解决方案--------------------
引用:
Quote: 引用:

int pstrcmp( const void *p1, const void *p2 ){//该函数是qsort函数的“回调”函数。两个参数的类型为指向常量的无类型指针
    return strcmp( *(char* const *)p1, *(char* const*)p2 );//将参数强制类型转换为char* const *类型,然后取其值,其值为char* const类型。
}

pstrcmp为什么在qsort里面没有参数

函数指针,这时windows 回调函数 的传递方式
对于C 就是函数指针,实参用函数地址,而函数名可以代表它的地址。
qsort 的实现代码里会通过函数指针,调用这个函数。
qsort VC有源码,当比较元素时,会调用实参 ,调用时比较函数的参数就是,被比较的两个数据.