So Im making a project and I litteraly tried to do the same as a friend but for some reason i keep getting the error: assignment to expression with array type, idk how to avoid.
So I have a struct called Aeroporto and a list lista_A made out of Aeroportos. I'm asking for the user to define what is going to be inside each Aeroporto and if there's nothing wrong with the input he provides then it would save the Aeroporto in the list list_A but its not working.
I ve not been able to progress for an entire day and i really could use a way out
#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
#define STR(x) #x
#define XSTR(x) STR(x)
typedef struct aeroporto
{
char id[LEN_ID + 1];
char pais[LEN_P + 1];
char cidade[LEN_CIDADE + 1];
} Aeroporto;
int soMaiusculas(char s[])
{
int i = 0, len = strlen(s);
for (;i<len;i++)
{
if (s[i]< 'A' || s[i]>'Z')
return 0;
}
return 1;
}
int main()
{
char input, p_id[LEN_ID ], p_pais[LEN_P ], p_cidade[LEN_CIDADE ], c;
int i = 0;
Aeroporto lista_a[AT];
scanf("%c",&input);
while (input != 'q'){
if (input == 'a')
{
scanf("%" XSTR(LEN_ID) "s",p_id);
scanf("%" XSTR(LEN_P) "s",p_pais);
scanf("%" XSTR(LEN_CIDADE) "[^\n]", p_cidade);
scanf("%*c");
printf("airport %s, %s, %s\n",p_id, p_pais, p_cidade);
if (!soMaiusculas(p_id))
printf("invalid airport ID\n");
else if (i==AT)
printf("too many airports\n");
/*else if (existeAero(lista_a, id))*/
else{
lista_a[i].id = p_id; //Now this is where the error is happening but following my //friend's advice it should work no?
lista_a[i].pais = p_pais;
lista_a[i].cidade = p_cidade;
i++;
}
}
scanf("%c",&input);
}
return 0;```