I spotted only a logic error, you flag as erased not the sent product but the last one, this is meaningless... I think that you don't need that flag ("eliminato").
Example:
You have to send the products a,b,c to the city x. Number of products = 3.
You send b and now in the x product list you have: a,c,c (b erased, c copied in the position of b)
The number of products now = 2.
Now you flag c as erased but it's useless.
The other thing I noticed is the use of typedef. I sudgested you to use it so you don't have to repeat struct a_product evrywhere so...
Code:
typedef struct a_product{
...
} product;
and
Code:
#
typedef struct a_city{
...
product listprod[m];
...
} city;
and so on...
Tomorrow morning I will read it better now i'm a little tired so I could miss some error.
edit:
I told you I could miss something...
From line 181 to 195:
Code:
for(j=0;j<city[i-1].num_prod;j++)
{
if(strcmp(prodotto,city[i-1].listprod[j].type)==0)
{
for(;j<city[i-1].num_prod-1;j++) //note nothing inizilized!
{
city[i-1].listprod[j].code_n=city[i-1].listprod[j+1].code_n;
strcpy(city[i-1].listprod[j].type,city[i-1].listprod[j+1].type);
city[i-1].listprod[j].prezzo=city[i-1].listprod[j+1].prezzo;
}
}
}