parent
f91615fc79
commit
9575c11d50
@ -1,68 +1,66 @@
|
|||||||
#include "partie1.h"
|
#include "partie1.h"
|
||||||
|
|
||||||
|
/*
|
||||||
ListeDept listenouv(void)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ListeDept insererEnTete(ListeDept l, char departement[], int nbP)
|
|
||||||
{
|
|
||||||
MaillonDept *m;
|
|
||||||
m = (MaillonDept *)malloc(sizeof(MaillonDept));
|
|
||||||
if (m == NULL)
|
|
||||||
{
|
|
||||||
printf("Fonction insererEnTete : problème malloc");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
strcpy(m->departement, departement);
|
|
||||||
m->nbP = nbP;
|
|
||||||
m->suiv = l;
|
|
||||||
return l;
|
|
||||||
}
|
|
||||||
|
|
||||||
ListeDept chargeListeDept(VilleIUT *tiut[])
|
ListeDept chargeListeDept(VilleIUT *tiut[])
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
ListeDept liste = listenouv();
|
ListeDept liste = listenouv();
|
||||||
FILE *file = fopen("informationsIUT.don", "r");
|
FILE *file = fopen("informationsIUT.txt", "r");
|
||||||
while (!feof(file))
|
while (!feof(file))
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
|
|
||||||
int chargementVilleIUT(VilleIUT *tiut[])
|
int chargementVillesIUT(VilleIUT *tiut[])
|
||||||
{
|
{
|
||||||
FILE *file = fopen("informationsIUT.don", "r");
|
FILE *file = fopen("informationsIUT.txt", "r");
|
||||||
VilleIUT villeiut;
|
|
||||||
char ville[30], dept[30], nomResp[30];
|
char ville[30], dept[30], nomResp[30];
|
||||||
int nbP, i = 0;
|
int nbP, i = 0, trouve;
|
||||||
if (file == NULL)
|
if (file == NULL)
|
||||||
{
|
{
|
||||||
printf("Fonction chargementVilleIUT : Problème lors de l'ouverture du fichier informations.don");
|
printf("Fonction chargementVillesIUT : Problème lors de l'ouverture du fichier informationsIUT.txt");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!feof(file))
|
while (!feof(file))
|
||||||
{
|
{
|
||||||
tiut[i] = (VilleIUT *)malloc(sizeof(VilleIUT));
|
fscanf(file, "%s%s%d", ville, dept, &nbP);
|
||||||
if (tiut[i] == NULL)
|
fgets(nomResp, 30, file);
|
||||||
|
trouve = recherche(tiut, i, ville);
|
||||||
|
if (trouve == 0)
|
||||||
{
|
{
|
||||||
printf("erreur malloc");
|
tiut[i] = (VilleIUT *)malloc(sizeof(VilleIUT));
|
||||||
exit(-1);
|
if (tiut[i] == NULL)
|
||||||
|
{
|
||||||
|
printf("Fonction chargementVillesIUT : Problème lors du malloc");
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
strcpy(tiut[i]->ville, ville);
|
||||||
|
i++;
|
||||||
}
|
}
|
||||||
fscanf(file, "%s%s%d", tiut[i]->ville, dept, &nbP);
|
|
||||||
fgets(nomResp, 30, file);
|
|
||||||
i++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int recherche(VilleIUT *tiut[], int nb, char val[])
|
||||||
|
{
|
||||||
|
for (int i = 0; i < nb; i++)
|
||||||
|
{
|
||||||
|
if (strcmp(tiut[i]->ville, val) == 0)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
void affichage(VilleIUT *tiut[], int nb)
|
void affichage(VilleIUT *tiut[], int nb)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < nb; i++)
|
for (int i = 0; i < nb; i++)
|
||||||
{
|
{
|
||||||
printf("%s\n", tiut[i]->ville);
|
printf("%s\n", tiut[i]->ville);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,9 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "../structures/structures.h"
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include "structures.h"
|
||||||
|
|
||||||
/* Fichier */
|
/* Fichier */
|
||||||
int chargementVilleIUT(VilleIUT *tiut[]);
|
int chargementVillesIUT(VilleIUT *tiut[]);
|
||||||
void affichage(VilleIUT *tiut[], int nb);
|
void affichage(VilleIUT *tiut[], int nb);
|
||||||
|
int recherche(VilleIUT *tiut[], int nb, char val[]);
|
||||||
/* File */
|
|
||||||
|
|
||||||
ListeDept listenouv(void);
|
|
@ -0,0 +1,21 @@
|
|||||||
|
#include "partie1.h"
|
||||||
|
|
||||||
|
ListeDept listenouv(void)
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ListeDept insererEnTete(ListeDept l, char departement[], int nbP)
|
||||||
|
{
|
||||||
|
MaillonDept *m;
|
||||||
|
m = (MaillonDept *)malloc(sizeof(MaillonDept));
|
||||||
|
if (m == NULL)
|
||||||
|
{
|
||||||
|
printf("Fonction insererEnTete : problème malloc");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
strcpy(m->departement, departement);
|
||||||
|
m->nbP = nbP;
|
||||||
|
m->suiv = l;
|
||||||
|
return l;
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
#include <string.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
typedef struct maillonDept
|
||||||
|
{
|
||||||
|
char departement[30];
|
||||||
|
int nbP;
|
||||||
|
char resp[30];
|
||||||
|
struct maillonDept *suiv;
|
||||||
|
} MaillonDept, *ListeDept;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
char ville[30];
|
||||||
|
ListeDept ldept;
|
||||||
|
} VilleIUT;
|
||||||
|
|
||||||
|
ListeDept listenouv(void);
|
||||||
|
ListeDept insererEnTete(ListeDept l, char departement[], int nbP);
|
Loading…
Reference in new issue