Ajout d’un argument pour lire le fichier test

This commit is contained in:
Rick 2020-12-14 16:26:50 +01:00
parent 22a8640852
commit 3b8ae68e9b
Signed by: Rick
GPG key ID: 9570A7DB7CB2F436

View file

@ -1,17 +1,27 @@
#include <stdio.h>
#define FILENAME "input"
//#define FILENAME "test"
#include <stdlib.h>
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 nexiste pas.\n", FILENAME);
printf("Le fichier %s nexiste pas.\n", filename);
return 1;
}