From 2d410ba50a5187f3d62629a50b5b3ec756e5766d Mon Sep 17 00:00:00 2001 From: bastien Date: Mon, 20 Apr 2026 11:52:11 +0000 Subject: [PATCH] Supprimer solution_jusque_exo3/main.c --- solution_jusque_exo3/main.c | 311 ------------------------------------ 1 file changed, 311 deletions(-) delete mode 100644 solution_jusque_exo3/main.c diff --git a/solution_jusque_exo3/main.c b/solution_jusque_exo3/main.c deleted file mode 100644 index d1b5d06..0000000 --- a/solution_jusque_exo3/main.c +++ /dev/null @@ -1,311 +0,0 @@ -#include -#include -#include - -#define MAX_CONTACTS 100 -#define MAX_NOM 50 -#define MAX_PRENOM 50 -#define MAX_TELEPHONE 15 -#define MAX_RUE 100 -#define MAX_CODE_POSTAL 10 -#define MAX_VILLE 50 -#define MAX_PAYS 50 -#define MAX_TYPE_TEL 20 -#define MAX_TELEPHONES 3 - -#define CHOIX_AJOUTER 27 -#define CHOIX_AFFICHER 32 -#define CHOIX_QUITTER 48 - -typedef struct{ - char type[MAX_TYPE_TEL]; - char numero[MAX_TELEPHONE]; -}Telephone; - - -typedef struct{ - char rue[MAX_RUE]; - char codePostal[MAX_CODE_POSTAL]; - char ville[MAX_VILLE]; - char pays[MAX_PAYS] -}adresse; - -// Structure d'un contact -typedef struct { - char nom[MAX_NOM]; - char prenom[MAX_PRENOM]; - int nbtel; - Telephone tel[MAX_TELEPHONES]; - adresse lieu; -} Contact; - - - -// Prototypes des fonctions -void ajouterContact(Contact *contacts, int *nbContacts); -void afficherContacts(Contact *contacts, int nbContacts); -void sauvegarderContacts(Contact *contacts, int nbContacts, const char *filename); -void chargerContacts(Contact *contacts, int *nbContacts, const char *filename); - -int main() { - Contact contacts[MAX_CONTACTS]; - int nbContacts = 0; - chargerContacts(contacts, &nbContacts, "contacts.txt"); - printf ("%d",nbContacts); - int choix; - do { - printf("\n%d. Ajouter un contact\n",CHOIX_AJOUTER); - printf("%d. Afficher les contacts\n",CHOIX_AFFICHER); - printf("%d. Quitter\n",CHOIX_QUITTER); - printf("Votre choix : "); - scanf("%d", &choix); - getchar(); // Pour éviter le problème de buffer avec scanf - - switch (choix) { - case CHOIX_AJOUTER: - ajouterContact(contacts, &nbContacts); - sauvegarderContacts(contacts, nbContacts, "contacts.txt"); - break; - case CHOIX_AFFICHER: - afficherContacts(contacts, nbContacts); - break; - case CHOIX_QUITTER: - printf("Au revoir !\n"); - break; - default: - printf("Choix invalide, veuillez réessayer.\n"); - } - } while (choix != CHOIX_QUITTER); - - return 0; -} - -// Fonction pour ajouter un contact -void ajouterContact(Contact *contacts, int *nbContacts) { - if (*nbContacts >= MAX_CONTACTS) { - printf("Le carnet d'adresses est plein !\n"); - return; - } - - printf("Nom : "); - fgets(contacts[*nbContacts].nom, MAX_NOM, stdin); - strtok(contacts[*nbContacts].nom, "\n"); - - printf("Prénom : "); - fgets(contacts[*nbContacts].prenom, MAX_PRENOM, stdin); - strtok(contacts[*nbContacts].prenom, "\n"); - - - - printf("Combien de numéro à enreistré pour ce contact (min 1 ; max %d): ",MAX_TELEPHONES); - scanf("%d",&contacts[*nbContacts].nbtel); - getchar(); - - while (contacts[*nbContacts].nbtel<1 || contacts[*nbContacts].nbtel>MAX_TELEPHONES){ - printf("Combien de numéro à enreistré pour ce contact (min 1 ; max %d): ",MAX_TELEPHONES); - scanf("%d",&contacts[*nbContacts].nbtel); - getchar();} - - for (int i=0;i