Getting error: expected expression before ‘{’ token in C while trying to verify struct

Getting error: expected expression before ‘{’ token in C while trying to verify struct

#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>

#define LEN_ID 3
#define LEN_P 30
#define LEN_CIDADE 50
#define AT 40

typedef struct aeroporto
{
    char id[LEN_ID + 1];
    char pais[LEN_P + 1];
    char cidade[LEN_CIDADE + 1];
} Aeroporto;

int findavailablespot(Aeroporto l[AT])
{
    int i = found = 0;
    for (;i<AT;i++) {
        if (l[i] = {"aaa","bbb","ccc"}) //Error in this line
            break;
        if (found)
            return i;
        else
            return -1;
    }    
}

所以我正在创建结构 aeroporto 然后是一个由 aeroportos 组成的向量,我想检查 {"aaa","bbb","ccc"} 是否出现在向量中。 帮忙?

抱歉格式化,这是新的

您必须使用 strcmp() 来比较字符串。对结构的所有成员执行此操作没有捷径,您必须单独测试每个成员并结合 &&.

你也忘记在跳出循环前设置found

int i = 0, found = 0;

for (;i<AT;i++) {
    if (strcmp(l[i].id, "aaa") == 0 && strcmp(l[i].pais, "bbb") == 0 && strcmp(l[i].cidade, "ccc")) {
        found = 1;
        break;
    }
}