From 3b8ae68e9b2328ae280b7ee68c4e0faa4367c10e Mon Sep 17 00:00:00 2001 From: Rick Date: Mon, 14 Dec 2020 16:26:50 +0100 Subject: [PATCH] =?UTF-8?q?Ajout=20d=E2=80=99un=20argument=20pour=20lire?= =?UTF-8?q?=20le=20fichier=20test?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- turbo_main.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/turbo_main.c b/turbo_main.c index eb156d2..7b81b65 100644 --- a/turbo_main.c +++ b/turbo_main.c @@ -1,17 +1,27 @@ #include - -#define FILENAME "input" -//#define FILENAME "test" +#include void prem_partie(FILE *ptr); void deux_partie(FILE *ptr); -int main() +int main(int argc, char *argv[]) { - FILE *ptr = fopen(FILENAME, "r"); + char *filename; + if (argc > 1) + { + char test[6] = "test"; + filename = test; + } + else + { + char input[6] = "input"; + filename = input; + } + + FILE *ptr = fopen(filename, "r"); if (ptr == NULL) { - printf("Le fichier %s n’existe pas.\n", FILENAME); + printf("Le fichier %s n’existe pas.\n", filename); return 1; }