commit
This commit is contained in:
parent
aa5045a797
commit
dec244496a
10 changed files with 148 additions and 76 deletions
BIN
a.exe
BIN
a.exe
Binary file not shown.
4
conf.c
4
conf.c
|
@ -11,6 +11,8 @@ int findConfId(ptConf confChain) {
|
|||
if (px -> id > max) {
|
||||
max = px -> id;
|
||||
}
|
||||
|
||||
px = px -> next;
|
||||
}
|
||||
|
||||
return max + 1;
|
||||
|
@ -50,6 +52,8 @@ int findListenerId(ptListener listenerChain) {
|
|||
if (px -> id > max) {
|
||||
max = px -> id;
|
||||
}
|
||||
|
||||
px = px -> next;
|
||||
}
|
||||
|
||||
return max + 1;
|
||||
|
|
10
data/confs
10
data/confs
|
@ -0,0 +1,10 @@
|
|||
1,coucou mes copains,Jean-Pierre,25,12,2023
|
||||
2,coucou mes copains,Jean-Pierre,25,12,2023
|
||||
3,coucou mes copains,Jean-Pierre,25,12,2023
|
||||
4,coucou mes copains,Jean-Pierre,25,12,2023
|
||||
5,test,tesst,21,120,2023
|
||||
6,test,tesst,21,120,2023
|
||||
7,test,tesst,21,120,2023
|
||||
8,test,tesst,21,120,2023
|
||||
9,test,tesst,21,120,2023
|
||||
10,test,tesst,21,120,2023
|
|
@ -0,0 +1,3 @@
|
|||
1,Roger,19,4
|
||||
2,Roger,19,4
|
||||
3,Roger,19,4
|
|
@ -0,0 +1,52 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include "conf.h"
|
||||
|
||||
void readConfs(ptConf confChain) {
|
||||
FILE *file = fopen("./data/confs", "r");
|
||||
char line[100];
|
||||
char *tokens[6];
|
||||
char *token;
|
||||
|
||||
if (file == NULL) {
|
||||
printf("ça marche pas.");
|
||||
return;
|
||||
}
|
||||
|
||||
while (fgets(line, sizeof(line), file)) {
|
||||
token = strtok(line, ",");
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (token != NULL && i < 6) {
|
||||
tokens[i] = token;
|
||||
i ++;
|
||||
token = strtok(NULL, ",");
|
||||
}
|
||||
|
||||
addConf(confChain, tokens[1], tokens[2], atoi(tokens[3]), atoi(tokens[4]), atoi(tokens[5]));
|
||||
}
|
||||
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void saveConf(ptConf confChain) {
|
||||
FILE *file = fopen("./data/confs", "w");
|
||||
ptConf px = confChain;
|
||||
while(px -> next != NULL){
|
||||
fprintf(file,"%d,%s,%s,%d,%d,%d\n",px -> id,px -> title,px -> speaker,px -> day,px -> month,px -> year);
|
||||
px = px -> next;
|
||||
}
|
||||
fclose(file);
|
||||
}
|
||||
|
||||
void saveListeners(ptListener listenerChain) {
|
||||
FILE *file = fopen("./data/listeners", "w");
|
||||
ptListener px = listenerChain;
|
||||
while(px -> next != NULL){
|
||||
fprintf(file,"%d,%s,%d,%d\n",px -> id,px -> name,px -> age,px -> level);
|
||||
px = px -> next;
|
||||
}
|
||||
fclose(file);
|
||||
}
|
|
@ -1,4 +1,10 @@
|
|||
#ifndef FILE_MANAHGER_H
|
||||
#define FILE_MANAHGER_H
|
||||
|
||||
#include "conf.h"
|
||||
|
||||
void readConfs();
|
||||
void saveConf(ptConf confChain);
|
||||
void saveListeners(ptListener listenerChain);
|
||||
|
||||
#endif // FILE_MANAHGER_H
|
22
main.c
22
main.c
|
@ -2,33 +2,27 @@
|
|||
#include <stdio.h>
|
||||
#include "conf.h"
|
||||
#include "screenManager.h"
|
||||
#include "fileManager.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
ptConf confChain = newConfChain();
|
||||
ptListener listenerChain = newListenerChain();
|
||||
|
||||
readConfs(confChain);
|
||||
|
||||
addConf(confChain, "test", "tesst", 21, 120, 2023);
|
||||
addConf(confChain, "test", "tesst", 21, 120, 2023);
|
||||
addConf(confChain, "test", "tesst", 21, 120, 2023);
|
||||
|
||||
addListener(listenerChain, "Roger", 19, 4);
|
||||
addListener(listenerChain, "Roger", 19, 4);
|
||||
addListener(listenerChain, "Roger", 19, 4);
|
||||
|
||||
ptConf px = confChain;
|
||||
ptListener py = listenerChain;
|
||||
//menu(confChain, listenerChain);
|
||||
|
||||
while (px -> next != NULL) {
|
||||
printf("title : %s\nspeaker : %s\n", px -> title, px -> speaker);
|
||||
printf("%d/%d/%d\n", px -> day, px -> month, px -> year);
|
||||
px = px -> next;
|
||||
}
|
||||
|
||||
while (py -> next != NULL) {
|
||||
printf("name: %s\nage: %d\nlevel: %d", py -> name, py -> age, py -> level);
|
||||
py = py -> next;
|
||||
}
|
||||
|
||||
//menu();
|
||||
saveConf(confChain);
|
||||
saveListeners(listenerChain);
|
||||
|
||||
return 0;
|
||||
}
|
BIN
main.exe
BIN
main.exe
Binary file not shown.
|
@ -2,6 +2,7 @@
|
|||
#include <stdlib.h>
|
||||
#include <windows.h>
|
||||
#include "screenManager.h"
|
||||
#include "conf.h"
|
||||
|
||||
void goToCoords(int x, int y)
|
||||
{
|
||||
|
@ -80,7 +81,7 @@ void drawMenu(char *options[], int lenght) {
|
|||
|
||||
}
|
||||
|
||||
void menuConf() {
|
||||
void menuConf(ptConf confChain, ptListener listenerChain) {
|
||||
char *options[] = {"1/ Voir la liste des conferences", "2/ Ajouter une conference", "3/ Suprimer une conference", "4/ Retour"};
|
||||
system("cls");
|
||||
drawMenu(options, 4);
|
||||
|
@ -101,16 +102,16 @@ void menuConf() {
|
|||
break;
|
||||
|
||||
case 4:
|
||||
menu();
|
||||
menu(confChain, listenerChain);
|
||||
break;
|
||||
|
||||
default:
|
||||
menu();
|
||||
menu(confChain, listenerChain);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void menuAbo() {
|
||||
void menuAbo(ptConf confChain, ptListener listenerChain) {
|
||||
char *options[] = {"1/ Voir la liste des abonnes", "2/ Ajouter un abonne", "3/ Suprimer un abonne", "4/ Retour"};
|
||||
system("cls");
|
||||
drawMenu(options, 4);
|
||||
|
@ -131,16 +132,16 @@ void menuAbo() {
|
|||
break;
|
||||
|
||||
case 4:
|
||||
menu();
|
||||
menu(confChain, listenerChain);
|
||||
break;
|
||||
|
||||
default:
|
||||
menu();
|
||||
menu(confChain, listenerChain);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void menu()
|
||||
void menu(ptConf confChain, ptListener listenerChain)
|
||||
{
|
||||
char *options[] = {"1/ Gestion des conferences", "2/ Gestion des abonnes", "3/ Participer a une conference", "4/ Voir la meilleure conference", "5/ Voir la participation a une conference", "6/ Quitter"};
|
||||
system("cls");
|
||||
|
@ -153,11 +154,11 @@ void menu()
|
|||
switch (choice)
|
||||
{
|
||||
case 1:
|
||||
menuConf();
|
||||
menuConf(confChain, listenerChain);
|
||||
break;
|
||||
|
||||
case 2:
|
||||
menuAbo();
|
||||
menuAbo(confChain, listenerChain);
|
||||
break;
|
||||
|
||||
case 3:
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef SREEN_MANAGER_H
|
||||
#define SREEN_MANAGER_H
|
||||
|
||||
void menu();
|
||||
#include "conf.h"
|
||||
|
||||
void menu(ptConf confChain, ptListener listenerChain);
|
||||
|
||||
#endif // SCREEN_MANAGER
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue