[Warning] assignment from incompatible pointer type 程序编译不知道哪里出错,运行没有问题
#include<stdio.h>#include<stdlib.h>
#include<string.h>
void sort (char *name[],int n)
{
int i,j,k;
int *temp;
for(i=0;i<n-1;i++)
{
k=i;
for(j=i+1;j<n;j++)
if(strcmp(name[k],name[j])>0)k=j;
if(k!=i)
{
temp=name[k];name[k]=name[i];name[i]=temp;
}
}
}
int main()
{
char *name[]={"H","D","C","S"};
int n=4,i;
sort(name,n);
for(i=0;i<4;i++)
printf("%s\n",name[i]);
system("pause");
return 0;
}