[Error] no match for 'operator[]' (operand types are 'contacts' and 'int')

问题遇到的现象和发生背景
void sort()//显示所有联系人(按姓名排序) 
{
    struct contacts *n;
    struct contacts contacts;
    struct contacts temp;
    int i;
    for(i=0;i<100;i++)
    {
        if(contacts[i].name>contacts[i+1].name)
        temp=contacts[i].name;
        contacts[i].name=contacts[i+1].name;
        contacts[i+1].name=temp;
    }
    for(n=head->next;n->next!=NULL;n=n->next)
    {
        printf("姓名\t性别\t出生日期\t单位\t邮编\t通信地址\t电话\tE-mail\n");
        printf("%s\t%s\t%s\t%s\t%s\t%s\t%s\t%s\n",n->name,n->sex,n->birth,n->work,n->youbian,n->add,n->tel,n->email);    
    }
}


问题相关代码,请勿粘贴截图
if(contacts[i].name>contacts[i+1].name)
        temp=contacts[i].name;
        contacts[i].name=contacts[i+1].name;
        contacts[i+1].name=temp;


运行结果及报错内容

[Error] no match for 'operator[]' (operand types are 'contacts' and 'int')

我的解答思路和尝试过的方法
我想要达到的结果

字符串比较用strcmp方法,contacts这个是一个结构体变量,不是数组哦。应该是使用contacts.name,contacts.next.name访问:

contacts这个是一个结构体,不是结构体数组,所以contacts[i]这么写的时候就会报错。
而且,contacts这个结构体也没有初始化,你就使用了。

img

temp应该定义为int