关于结构体的一段程序,哪里出错了?
#include<stdio.h>#include<string.h>
typedef struct census
{
char city[20];
long population;
double culture;
}A;
main()
{
A city[]={
{"Beijing",100000,3.0},
{"Jinan",10000,3.1},
{"New york",10000000,3.2},
{"Boshan",1000,3.5}};
int index;
void line(A,int);
index=sizeof(city)/sizeof(A);
line(city,index);
}
void line(A line[],int index)
{
int i,j;
A a;
for(i=0;i<index-1;i++)
{
for(j=i+1;j<index;j++)
if(strcmp(line[i].city,line[j].city)>0)
{
a=line[i];
line[i]=line[j];
line[j]=a;
}
}
for(i=0;i<index;i++)
printf("%s %d %f",line[i].city,line[i].population,line[i].culture);
}