Projet tutoré 3 - Graphes
Référence du fichier ProjetGraphes.cpp

Fichier contenant la fonction main. Plus de détails...

#include <iostream>
#include <Windows.h>
#include "CGraphe.h"
#include "CSommet.h"
#include "CArc.h"
#include "CException.h"
#include "conio.h"

Aller au code source de ce fichier.

Fonctions

int main (int argc, char *argv[])
 

Description détaillée

Fichier contenant la fonction main.

Avertissement
La fonction main nécessite au moins 1 chemin vers un fichier pour traiter la création d'un graphe, sinon fin de programme
Auteur
Guillaume ELAMBERT
Clément NONCHER-GILLET
Date
2021

Définition dans le fichier ProjetGraphes.cpp.

Documentation des fonctions

◆ main()

int main ( int  argc,
char *  argv[] 
)

La fonction principale.

Avertissement
Nécessite au moins 1 chemin vers un fichier pour traiter la création d'un graphe, sinon fin de programme
Paramètres
argcLe nombre d'arguments passés au programme
argvLa liste des arguments passés au programme
Renvoie
0 => l'exécution s'est faite sans erreur

Définition à la ligne 30 du fichier ProjetGraphes.cpp.

31 {
32  // Set console code page to UTF-8 so console known how to interpret string data
33  SetConsoleOutputCP(CP_UTF8);
34 
35  // Enable buffering to prevent VS from chopping up UTF-8 byte sequences
36  setvbuf(stdout, nullptr, _IOFBF, 1000);
37 
38 
39  if (argc > 1) {
40 
41  CGraphe *GPHLeGraphe = NULL;
42  CGraphe *GPHLeGrapheInverse = NULL;
43 
44  //On parcourt l'ensemble des chemins passés en paramètre
45  for (int i = 1; i < argc; ++i) {
46  try {
47  printf(i > 1 ? "\n\n" : "");
48 
49 
50  printf("----- GRAPHE DU FICHIER \"%s\" -----\n\n", argv[i]);
51  GPHLeGraphe = new CGraphe(argv[i], true);
52  GPHLeGraphe->GPHAfficherGraphe();
53 
54 
55  printf("\n----- GRAPHE INVERSE DU FICHIER \"%s\" -----\n\n", argv[i]);
56  GPHLeGrapheInverse = &GPHLeGraphe->GPHRenverserGraphe();
57  GPHLeGrapheInverse->GPHAfficherGraphe();
58 
59  cout << endl << endl;
60 
61  delete GPHLeGraphe;
62  delete GPHLeGrapheInverse;
63  }
64  //On gère les erreurs de création du graphe et d'inversion du graphe
65  catch (CException EXCELevee) {
66  cerr << EXCELevee.EXCGetMessage();
67  }
68  }
69  }
70  else {
71  cout << "Il faut passer au moins un fichier en paramètre.\n";
72  }
73 
74  cout << "\n\nAppuyez sur une touche pour fermer" << endl;
75  _getch();
76  return 0;
77 }
CGraphe
Classe du graphe.
Definition: CGraphe.h:41
CGraphe::GPHAfficherGraphe
void GPHAfficherGraphe()
Definition: CGraphe.cpp:571
CException
Classe d'exception personnalisée.
Definition: CException.h:25
CGraphe::GPHRenverserGraphe
CGraphe & GPHRenverserGraphe()
Definition: CGraphe.cpp:594
CException::EXCGetMessage
const char * EXCGetMessage(void)
Definition: CException.cpp:71