#include<stdio.h>
#include<string.h>
void bubsort(char *name[],int n)
{
int k,m,i,j;
char d;
k=0;
m=n-1;
while(k<m)
{
j=m-1;
for(i=0;i<=j;i++)
if(strcmp(name[i],name[i+1]))
{d=*name[i];*name[i]=*name[i+1];*name[i+1]=d;m=i;}
for(i=n-1;i>=1;i--)
if(strcmp(name[i],name[i+1]))
{d=*name[i];*name[i]=*name[i-1];*name[i-1]=d;k=i;}
}
return;
}
main()
{
int i;
char *name[]={"zhang","gou","xu","zheng","mao","zhao","li","bai","qing"};
for(i=0;i<=8;i++)
{printf("%s ",*name[i]);}
_** void bubsort(name,9);**_
printf("\n");
for(i=0;i<=8;i++)
printf("%s ",*name[i]);
printf("\n");
}
這三個報錯都是在粗體斜體部分,不明白是哪裡錯了?求指點
1 error C2143: 語法錯誤 : 缺少“;”(在“類型”的前面)
2 IntelliSense: 不允許使用不完整的類型
3 IntelliSense: 應輸入“)”
main函數中有三處語法問題,修改之後如下
main()
{
int i;
char *name[]={"zhang","gou","xu","zheng","mao","zhao","li","bai","qing"};
for(i=0;i<=8;i++)
{printf("%s ",name[i]);}
bubsort(name,9);
printf("\n");
for(i=0;i<=8;i++)
printf("%s ",name[i]);
printf("\n");
}