版主威武,在使用指针的时候必须确保指针是有效的。
void swap(char* p1,char* p2){
    char* temp = NULL;
    int len1 = strlen(p1);
    int len2 = strlen(p2);
    if(len1 > len2)
        temp = (char*)malloc(len1+1);
    else 
        temp = (char*)malloc(len2+1);
    if(temp == NULL)exit(-1);
    if(strcmp(p1,p2)>0){
        strcpy(temp,p1);
        strcpy(p1,p2);
        strcpy(p2,p1);
    }
}