Correction Bug pointeur menu 3 vers 1
fuite mémooire car changement de pointeur qui est le pointeur du tableau. Si on modif se pointeur ça modif le tableau. Donc utilisation de memcpy pour ne pas changé le pointeur
This commit is contained in:
16
VANDAMME32.c
16
VANDAMME32.c
@@ -160,6 +160,7 @@ int main()
|
||||
localiserFichiersClients(&fichierClient);
|
||||
nbrClient = nombreClients(&fichierClient);
|
||||
recupererClients(&fichierClient, &clientTab);
|
||||
afficherListeClients(clientTab);
|
||||
while(w)
|
||||
{
|
||||
if(clientTab)
|
||||
@@ -186,18 +187,13 @@ int main()
|
||||
if(encoderClient(client, clientTab))
|
||||
{
|
||||
afficherClient(client, &date);
|
||||
printf("1\n");
|
||||
fseek(fichierClient.txt, 0, SEEK_END);
|
||||
printf("1\n");
|
||||
insertClientTabTrier(client, &clientTab);
|
||||
printf("1\n");
|
||||
sauvegarderTabClientFile(&fichierClient, clientTab);
|
||||
printf("1\n");
|
||||
w = gestionClient(client, &date, &fichierClient);
|
||||
printf("1\n");
|
||||
nbrClient++;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if(clientTab)
|
||||
{
|
||||
@@ -220,7 +216,7 @@ int main()
|
||||
} while(idClient > nbrClient);
|
||||
if(idClient != 0)
|
||||
{
|
||||
client = *(clientTab+(idClient-1));
|
||||
memcpy(client, *(clientTab+(idClient-1)), sizeof(Client));
|
||||
w = gestionClient(client, &date, &fichierClient);
|
||||
}
|
||||
break;
|
||||
@@ -292,12 +288,13 @@ Bool encoderClient(Client * client, Client ** clientsTab)
|
||||
if(choix != 'a')
|
||||
{
|
||||
printf("Le client existe deja. Reesayer ? (Y|n)");clean_keyboard();scanf("%c", &choix);
|
||||
if(!((choix|0b00100000) == 'y'))
|
||||
if(((choix|0b00100000) != 'y'))
|
||||
return FALSE;
|
||||
}
|
||||
while(!(printf("\nNom client :") && clean_keyboard() && fgets(client->nom,__STRLEN__,stdin) != NULL));
|
||||
while(!(printf("\nPrenom client :") && clean_keyboard() && fgets(client->prenom,__STRLEN__,stdin) != NULL));
|
||||
choix = 'b';
|
||||
cleanFgets(client->nom);cleanFgets(client->prenom);
|
||||
} while(rechercheClientArray(client->nom, client->prenom, clientsTab, 0)); //On ne sais pas facilement acceder au tris donc par default non trier
|
||||
|
||||
while(!(printf("Entrez la rue :") && clean_keyboard() && fgets(client->adresse.rue,__STRLEN__,stdin) != NULL));
|
||||
@@ -306,7 +303,6 @@ Bool encoderClient(Client * client, Client ** clientsTab)
|
||||
while(!(printf("\nEntrez le code postal :") && clean_keyboard() && scanf("%d", &(client->adresse.codePostal)) ));
|
||||
|
||||
cleanFgets(client->adresse.rue);cleanFgets(client->adresse.numero);cleanFgets(client->adresse.localite);
|
||||
cleanFgets(client->nom);cleanFgets(client->prenom);
|
||||
while(!(printf("\n Entrez le numero de tel. :") && clean_keyboard() &&fgets(client->contact.telephone,13,stdin)));
|
||||
while(!(printf("\nEntrez l'adresse email :") && clean_keyboard() &&fgets(client->contact.email,__STRLEN__,stdin)));
|
||||
cleanFgets(client->contact.telephone);cleanFgets(client->contact.email);
|
||||
@@ -1196,7 +1192,7 @@ ListeArticle * rechercheElemListe(ListeArticle * listeArticle)
|
||||
|
||||
Bool rechercheClientArray(char *nom, char * prenom, Client ** clients, Bool tri)
|
||||
{
|
||||
if(!clients)
|
||||
if(!clients && !(*clients))
|
||||
return FALSE;
|
||||
if(tri && 1==2) // a faire
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user