Error al incrementar variable
Publicado por Pepe (21 intervenciones) el 24/09/2020 19:27:02
Buenas tardes, me ha surgido un problema. En una estructura tengo una variable para controlar el total de contratos realizados, ya que no pueden superar las 3 unidades. Para ello cada vez que meto un contrato quiero incrementar la variable en 1, pero no me deja.
Estructuras que utilizo:
La funcion sería esta:
El trozo de codigo de la funcion que me falla es este:
Estructuras que utilizo:
1
2
3
4
5
6
7
8
typedef struct {
int month;
int year;
tWorkspace workspace;
int tAnnex;
tPartner idClient;
tContractAnnex Annex;
} tContract;
1
2
3
4
5
6
7
8
9
typedef struct {
tPartner *clients;
tWorkspace *workspace;
tContract *contract;
int totalContracts;
int totalClients;
int totalWorkspace;
} tCoworking;
La funcion sería esta:
1
void add_contract(tCoworking *c, int idClient, int idWorkspace, int month, int year){
El trozo de codigo de la funcion que me falla es este:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
if (find_contract (*c, idClient, idWorkspace, month,year)){
printf("ERROR: Workspace %d is reserved in period %d/%d \n", idWorkspace, month, year );
}
else if (find_contract_user (*c, idClient)){
printf("Partner %d has the maximum of annexes allowed in period %d/%d \n", idClient, month, year );
}
else{
c->contract[c->totalContracts].idClient.idClient = idClient;
c->contract[c->totalContracts].month= month;
c->contract[c->totalContracts].year= year;
c->contract[c->totalContracts].workspace.idWorkspace = idWorkspace;
c->contract[c->totalContracts].tAnnex++;
c->totalContracts++;
}
Valora esta pregunta


0