From fdcdabebc182c3bc0a246c6efff6cae31c25e82f Mon Sep 17 00:00:00 2001 From: ALittlePatate Date: Sat, 3 Sep 2022 16:32:19 +0200 Subject: [PATCH] added args to the program you can turn on/off colors, and set the graph size --- polynome.c | 18 ++++++++++++++++-- polynome.h | 6 +++--- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/polynome.c b/polynome.c index 96dac1c..a0991b9 100644 --- a/polynome.c +++ b/polynome.c @@ -201,7 +201,7 @@ enum STATUS Dessiner_Graph(Poly* poly) { int main(int argc, char* argv[]) { if (argc < 4) { - fprintf(stderr, "%s", "[-] usage : poly.exe a b c [--colors]\n"); + fprintf(stderr, "%s", "[-] usage : poly.exe a b c [--size 20] [--colors]\n"); return 1; } @@ -210,7 +210,21 @@ int main(int argc, char* argv[]) { float c = atof(argv[3]); if (argc > 4) { - use_colors = true; + if (strcmp(argv[4], "--size") == 0) { + if (argc >= 5) { + LONGUEUR_X = strtol(argv[5], NULL, 10); + LONGUEUR_Y = LONGUEUR_X; + } + } + + if (strcmp(argv[4], "--colors") == 0) { + use_colors = true; + } + if (argc >= 7) { + if (strcmp(argv[6], "--colors") == 0) { + use_colors = true; + } + } } printf("[+] Processing %.3fx^2%.3fx%.3f\n", a, b, c); diff --git a/polynome.h b/polynome.h index 371e2e4..7d9e1d4 100644 --- a/polynome.h +++ b/polynome.h @@ -25,9 +25,9 @@ enum STATUS Calcul_Sommet(Poly* poly); enum STATUS Calcul_Fonction(Poly* poly, float x, float *out); enum STATUS Calcul_Derivee(Poly* poly, float x, float *out); -#define LONGUEUR_X 20 -#define LONGUEUR_Y 20 +int LONGUEUR_X = 20; +int LONGUEUR_Y = 20; void Dessiner_Separateur(); -bool use_colors = false; +int use_colors = false; enum STATUS Dessiner_Graph(Poly* poly); int main(); \ No newline at end of file