|
main()
{
void sort(char *name[],int n);
void printf(char * name[],int n);
char *name[]={"Follow me","BASIC","Great Wall","Fortran","computer design"};
int n=5;
sort (name,n);
printf(name,n);
}
void sort(char *name[],int n)
{char * temp;
int i,j,k;
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;name=name[k];name[k]=temp;}
}
}
void printf(char *name[],int n)
{
int i;
for (i=0;i<n;i++)
printf("%s\n",name);
}
[guest@localhost guest]$ gcc -o ex10_27.out ex10_27.c
ex10_27.c: In function `main':
ex10_27.c:7: warning: conflicting types for built-in function `printf'
ex10_27.c:7: warning: extern declaration of `printf' doesn't match global one
ex10_27.c: At top level:
ex10_27.c:27: warning: conflicting types for built-in function `printf'
ex10_27.c: In function `printf':
ex10_27.c:30: warning: passing arg 1 of `printf' from incompatible pointer type
ex10_27.c:30: warning: passing arg 2 of `printf' makes integer from pointer without a cast
用gdb运行提示段错误.请帮忙解释一下.3x |
|