编程关于指针数组的问题报错,求指教
#include<stdio.h>#include<string.h>
int main()
{
char sort(char *name[],int n);
char print(char *name[],int n);
char *name[]={"i","love","you"};
int n=3;
sort(name,3);
print(name,3);
return 0;
}
char sort(char *name[],int n)
{
int i,j,k;
char *t;
for(i=0;i<n-1;i++)
{
k=i;
for(j=i+1;j<n-1;j++)
if(strcmp(name[i],name[j])>0)
k=j;
if(k!=i)
{
t=name[i];
name[i]=name[j];
name[j]=t;
}
}
}
void print(char *name[],int n)
{
for(int i=0;i<n;i++)
printf("%s\n",name[i]);
}
[此贴子已经被作者于2017-4-24 21:01编辑过]