parent
12921f86f9
commit
833eae8748
@ -0,0 +1,4 @@
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
|
||||
char *readAdress(FILE *flot);
|
@ -1 +1,2 @@
|
||||
#define tmaxTravaux 8
|
||||
#define tmaxTravaux 8
|
||||
|
||||
|
@ -1,5 +0,0 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
int rechTravaux(char travauxName[], Offre *tabTravaux[]);
|
@ -0,0 +1,29 @@
|
||||
#include "../includes/charge.h"
|
||||
|
||||
char *readAdress(FILE *flot)
|
||||
{
|
||||
char *adresse, *s, aux[5];
|
||||
int i=0, tmax=5;
|
||||
adresse = (char *)malloc(sizeof(char)*tmax);
|
||||
fgets(adresse, 5, flot);
|
||||
|
||||
while (adresse[i]!='\n')
|
||||
{
|
||||
if (i==tmax)
|
||||
{
|
||||
tmax+=5;
|
||||
s = (char *)realloc(adresse, tmax*sizeof(char));
|
||||
if (s==NULL)
|
||||
{
|
||||
printf("Erreur reallocation pour str adresse\n");
|
||||
exit(1);
|
||||
}
|
||||
adresse=s;
|
||||
fgets(aux, 5, flot);
|
||||
strcat(adresse, aux);
|
||||
}
|
||||
i++;
|
||||
}
|
||||
adresse[strlen(adresse)-1]='\0';
|
||||
return adresse;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
#include "../includes/structures.h"
|
||||
#include "../includes/recherche.h"
|
||||
#include "../includes/main.h"
|
||||
|
||||
int rechTravaux(char *travauxName, Offre *tabTravaux[], int tlog)
|
||||
{
|
||||
int deb=0, end=tmaxTravaux-1, mid; //On utilise la taille max de travaux car travaux est un tableau constant, sa taille max est égale à sa taille logique.
|
||||
while(deb<=end)
|
||||
{
|
||||
mid = deb+end /2;
|
||||
if (strcmp(travauxName, tabTravaux[mid]->travaux)==0)
|
||||
return mid;
|
||||
if (strcmp(travauxName, tabTravaux[mid]->travaux) < 0)
|
||||
end=mid-1;
|
||||
else
|
||||
deb=mid+1;
|
||||
}
|
||||
return -1;
|
||||
}
|
Loading…
Reference in new issue