IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C Discussion :

mini-projet: gestion des ordinateurs


Sujet :

C

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Décembre 2011
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant
    Secteur : High Tech - Matériel informatique

    Informations forums :
    Inscription : Décembre 2011
    Messages : 1
    Par défaut mini-projet: gestion des ordinateurs
    Bonsoir tout le monde
    Je suis en 2ème année FPL et j'ai un mini-projet en langage C. Je dois créer en C le truc de la gestion des ordinateurs j'essaye d'écrire un code source mais ça ne marche pas bien surtout pour le tri et l'affichage.
    S'il vous plait peut m'aider ?

    svp merci d'avance.
    Fichiers attachés Fichiers attachés

  2. #2
    Membre émérite Avatar de orfix
    Homme Profil pro
    Inscrit en
    Avril 2007
    Messages
    707
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Maroc

    Informations professionnelles :
    Secteur : High Tech - Produits et services télécom et Internet

    Informations forums :
    Inscription : Avril 2007
    Messages : 707
    Par défaut
    Tu devrais peut-être commencer par renommer ton fichier en ordinateur.c puis recompiler ton programme et essayer de corriger ce qui suit:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
     
    ordinateur.c: In function ‘ajouter_un_ordinateur’:
    ordinateur.c:58: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[30]’
    ordinateur.c:62: warning: format ‘%d’ expects type ‘int *’, but argument 2 has type ‘float *’
    ordinateur.c:66: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[30]’
    ordinateur.c:68: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[30]’
    ordinateur.c:70: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[30]’
    ordinateur.c:72: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[30]’
    ordinateur.c:74: warning: format ‘%f’ expects type ‘float *’, but argument 2 has type ‘int *’
    ordinateur.c: In function ‘ajouter_plusieur_ordinateurs’:
    ordinateur.c:96: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[30]’
    ordinateur.c:98: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[30]’
    ordinateur.c:100: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[30]’
    ordinateur.c:102: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[30]’
    ordinateur.c:104: warning: format ‘%f’ expects type ‘float *’, but argument 2 has type ‘int *’
    ordinateur.c: In function ‘rechercher_par_nom’:
    ordinateur.c:138: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[30]’
    ordinateur.c:136: warning: unused variable ‘typ_sys’
    ordinateur.c: In function ‘trier’:
    ordinateur.c:197: warning: statement with no effect
    ordinateur.c:198: warning: statement with no effect
    ordinateur.c:199: warning: statement with no effect
    ordinateur.c:202: warning: statement with no effect
    ordinateur.c:203: warning: statement with no effect
    ordinateur.c:211: warning: statement with no effect
    ordinateur.c: In function ‘modifier’:
    ordinateur.c:249: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[30]’
    ordinateur.c:257: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[30]’
    ordinateur.c:259: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[30]’
    ordinateur.c:261: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[30]’
    ordinateur.c:263: warning: format ‘%s’ expects type ‘char *’, but argument 2 has type ‘char (*)[30]’
    ordinateur.c: In function ‘supprimer’:
    ordinateur.c:281: warning: statement with no effect
    ordinateur.c:284: warning: statement with no effect
    ordinateur.c:286: warning: statement with no effect
    ordinateur.c:287: warning: statement with no effect
    ordinateur.c:288: warning: statement with no effect
    ordinateur.c: In function ‘main’:
    ordinateur.c:303: warning: unused parameter ‘argc’
    ordinateur.c:303: warning: unused parameter ‘argv’
    Ensuite il faut poser des questions précises... quelques conseils au passage:

    • Évites l'utilisation des variables globales.
    • Ouvres ton livre de C et relis le chapitre concernant les fonctions.
    • '=' n'a pas le même sens que '=='
    • Si tu peux éviter scanf() fait le sinon apprend à l'utiliser correctement.
    • Si tu veux que ton programme soit portable évite l'utilisation de system().

  3. #3
    Membre éprouvé
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2012
    Messages
    53
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2012
    Messages : 53
    Par défaut
    Salut,
    pour la fonction d'affichage, tu as commis une erreur simple et à éviter
    l'accolade doit être juste après la boucle pas le printf, code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    void afficher()
    {     
          for(i=1;i<=nbordi;i++)
          {   //cette accolade doit être ici
     
                 printf("\n l'ordinateurs %d\n\n ",nbordi); 
                 printf("-------------------------\n");
     
                 //{ et pas ici           
     
                 printf("Nom : %s\n",liste_ordi[i].nom); 
                 printf("Matricul : %d\n",liste_ordi[i].matricul);
                 printf("La capacite de la RAM : %f Go \n",liste_ordi[i].RAM);
                 printf("La capacite du disque dur  : %f Go\n",liste_ordi[i].disque_dur);
                 printf("Fabricant : %s\n",liste_ordi[i].fabricant);
                 printf("La marque : %s\n",liste_ordi[i].model);
                 printf("Processeur : %s\n",liste_ordi[i].proces);
                 printf("Systeme d'exploitation : %s\n",liste_ordi[i].sys_explt); 
                 printf("Type de systeme : %d\n",liste_ordi[i].typ_sys);     
         }
    }
    j'ai essayé le code, maintenant l'affichage marche bien.
    bon chance.

  4. #4
    Membre éprouvé
    Homme Profil pro
    Étudiant
    Inscrit en
    Novembre 2012
    Messages
    53
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 34
    Localisation : Maroc

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Novembre 2012
    Messages : 53
    Par défaut
    Encore des remarques:
    premièrement, les conseils de Mr orfix sont très importants, en plus:
    - parfois tu utilise des %f pour des entiers ou l'inverse (%d pour des flottants)
    - pense bien à organiser ton code, et y ajouter des indentations, pour une meilleur lisibilité
    - pourquoi pas ajouter des commentaires
    - la fonction ajouter plusieurs ordinateurs peut appeler la premier en ajoutant juste une simple boucle, pourquoi la redondance, puisqu'ils ont le même cœur.
    Vérifie l'attribut "Type de systeme", des erreurs de lectures et d'écriture y parvient (scanf et printf), le contenue de la variable ne s'affiche pas correctement. regarde cet extrait de code:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    void trier()
    {
         char tmpstr[30];
         float tmp;       
     
              for( i = 1 ; i <= nbordi ; i++ )
                    for( j=i+1 ; j < nbordi ; j++ )          
                       if ( liste_ordi[i].matricul < liste_ordi[j].matricul )
                       { 
                                     tmp = liste_ordi[j].matricul; // il s'était '==' pas une seul '='
                                      liste_ordi[j].matricul = liste_ordi[i].matricul;                
                                      liste_ordi[i].matricul = tmp;
     
                                      tmp = liste_ordi[j].RAM;
                                      liste_ordi[j].RAM = liste_ordi[i].RAM;                
                                      liste_ordi[i].RAM = tmp;
     
                                      tmp = liste_ordi[j].disque_dur; /* le contenue est affecté à tmp */ 
                                      liste_ordi[j].disque_dur = liste_ordi[i].disque_dur;                
                                      liste_ordi[i].disque_dur = disque_dur; /* et récupérer par disque_dur */
     
                                      tmp = liste_ordi[j].typ_sys;
                                      liste_ordi[j].typ_sys = liste_ordi[i].typ_sys;                
                                      liste_ordi[i].typ_sys = tmp;
     
     
                                      strcpy(tmpstr, liste_ordi[j].nom);
                                      strcpy(liste_ordi[j].nom, liste_ordi[i].nom);
                                      strcpy(liste_ordi[i].nom, liste_ordi[j].nom);
     
                                      strcpy(tmpstr, liste_ordi[j].fabricant);
                                      strcpy(liste_ordi[j].fabricant, liste_ordi[i].fabricant);
                                      strcpy(liste_ordi[i].fabricant, liste_ordi[j].fabricant);  
     
                                      strcpy(tmpstr, liste_ordi[j].model);
                                      strcpy(liste_ordi[j].model, liste_ordi[i].model);
                                      strcpy(liste_ordi[i].model, liste_ordi[j].model);
     
                                      strcpy(tmpstr, liste_ordi[j].proces);
                                      strcpy(liste_ordi[j].proces, liste_ordi[i].proces);
                                      strcpy(liste_ordi[i].proces, liste_ordi[j].proces);
     
     
                                      strcpy(tmpstr, liste_ordi[j].sys_explt);
                                      strcpy(liste_ordi[j].sys_explt, liste_ordi[i].sys_explt);
                                      strcpy(liste_ordi[i].sys_explt, liste_ordi[j].sys_explt);                             
                       }
    }
    peut être que la fonction ne marche pas encore, c'est juste des notifications.

Discussions similaires

  1. [WS 2003] Gestion des ordinateurs dans l'AD
    Par _Snoopy dans le forum Windows Serveur
    Réponses: 8
    Dernier message: 04/09/2013, 14h27
  2. Projet Gestion des problemes
    Par Aero'ix dans le forum UML
    Réponses: 0
    Dernier message: 18/04/2013, 13h29
  3. Gestion des ordinateurs ( MCD)
    Par seksaki dans le forum Merise
    Réponses: 2
    Dernier message: 06/02/2010, 15h27

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo