Code:
#typedef struct a_city{
# int cod_num;
# char name[15];
# char pos[7];
# char cap[6];
# product listprod[MAX_PRODOTTI];
# int num_prod;
#}city;
#
#//dati delle citta'
#char city_data [CITTA*3][15]={ "Avellino","Sud","83100",
# "Benevento","Sud","82100",
# "Firenze","Centro","50100",
# "Genova","Nord","16100",
# "Milano","Nord","20100",
# "Napoli","Sud","80100",
# "Perugia","Centro","06100",
# "Roma","Centro","00100",
# "Torino","Nord","10100",
# "Venezia","Nord","30100"};
This would be better if you made 'city' its own structure, and then made another one that had a city + its product.
Code:
typedef struct a_city{
int cod_num; /* remove this if it's not actually something relevant, and stick it in the other structure */
char name[15];
char pos[7];
char cap[6];
} cityinfo;
typedef struct productioninfo {
cityinfo thiscity;
product listprod[MAX_PRODOTTI];
int num_prod;
} cityproduction;
That way, the whole problem you are having with swapping citys around would be much easier to fix. Plus, your city list would instead look like:
Code:
cityinfo cities[] = {
{ /*whatever that number is... or remove it */ 5, "Benevento","Sud","82100", },
...the rest of the cities...
};
Quzah.