Ajout d’un argument pour lire le fichier test
This commit is contained in:
parent
22a8640852
commit
3b8ae68e9b
1 changed files with 16 additions and 6 deletions
22
turbo_main.c
22
turbo_main.c
|
@ -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 n’existe pas.\n", FILENAME);
|
||||
printf("Le fichier %s n’existe pas.\n", filename);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue