This commit is contained in:
Lukian LEIZOUR 2023-11-20 10:24:31 +01:00
parent 50ea8f2735
commit aa5045a797
4 changed files with 41 additions and 10 deletions

34
conf.c
View file

@ -3,6 +3,19 @@
#include <string.h>
#include "conf.h"
int findConfId(ptConf confChain) {
ptConf px = confChain;
int max = 0;
while (px -> next != NULL) {
if (px -> id > max) {
max = px -> id;
}
}
return max + 1;
}
ptConf newConfChain() {
ptConf confChain = (ptConf) malloc(sizeof(tConf));
@ -11,13 +24,14 @@ ptConf newConfChain() {
return confChain;
}
void addConf(ptConf confChainStart, char title[], char speaker[], int day, int month, int year) {
ptConf px = confChainStart;
void addConf(ptConf confChain, char title[], char speaker[], int day, int month, int year) {
ptConf px = confChain;
while (px -> next != NULL) {
px = px -> next;
}
px -> id = findConfId(confChain);
px -> day = day;
px -> month = month;
px -> year = year;
@ -28,6 +42,19 @@ void addConf(ptConf confChainStart, char title[], char speaker[], int day, int m
px -> next -> next = NULL;
}
int findListenerId(ptListener listenerChain) {
ptListener px = listenerChain;
int max = 0;
while (px -> next != NULL) {
if (px -> id > max) {
max = px -> id;
}
}
return max + 1;
}
ptListener newListenerChain() {
ptListener listenerChain = (ptListener) malloc(sizeof(tListener));
@ -44,6 +71,7 @@ void addListener(ptListener listenerChain, char name[], int age, int level) {
px = px -> next;
}
px -> id = findListenerId(listenerChain);
strcpy(px -> name, name);
px -> age = age;
px -> level = level;
@ -51,4 +79,4 @@ void addListener(ptListener listenerChain, char name[], int age, int level) {
px -> next = (ptListener) malloc(sizeof(tListener));
px -> next -> next = NULL;
px -> next -> prev = px;
}
}