Hello,
I have a product sales management program where I have a structure for storing product data, another to store customer data and another to store sales data. When I insert a new sale has to be associated with a existing product serial number and the id of a existing customer. How do i guarantee when data products and customers struct are changed the sales struct is updated?
Here's what I have:
Code:
typedef struct{
char serialnumber[10]
char description[100]
float price
}stproducts;
typedef struct{
int id;
char name[50]
char adress[100]
int phonenumber
}stcustomers;
typedef struct{
int idcustomersale;
char serialnumberproductsale[10]
float endprice;
}stsales;
Code:
int main()
{
stproducts pr[1000];
int countproducts =0;
stcustomers cust[500];
int countcustomers=0;
stsales sal[1000];
int countsales=0;
}
part of the function insert sale:
Code:
void insertsale(stsales sal[], int *countsales, stproduct pr[], int countproduct,stcustomers cust[], int countcustomers)
{
char psale[10];
int number;
consultproducts(pr, countproducts);
consultcustomers(cust,countcustomers);
printf("insert the product serial number of the sale:");
fgets(psale, sizeof psale, stdin);
strcpy(sal[*countsales].serialnumberproductsale,psale);
printf("insert the customer id of the sale:");
scanf ("%d", &number);
sal[*countsales].idcustomersale=number;
//....................
}
For example let's imagine that the id field is changed on the customer struct, automatically the customer id associated with the sale (idcustomersale) must also be updated.
please help !!!!