added args to the program

you can turn on/off colors, and set the graph size
This commit is contained in:
ALittlePatate
2022-09-03 16:32:19 +02:00
parent 3efc546a1f
commit fdcdabebc1
2 changed files with 19 additions and 5 deletions

View File

@@ -201,7 +201,7 @@ enum STATUS Dessiner_Graph(Poly* poly) {
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
if (argc < 4) { 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; return 1;
} }
@@ -210,7 +210,21 @@ int main(int argc, char* argv[]) {
float c = atof(argv[3]); float c = atof(argv[3]);
if (argc > 4) { 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); printf("[+] Processing %.3fx^2%.3fx%.3f\n", a, b, c);

View File

@@ -25,9 +25,9 @@ enum STATUS Calcul_Sommet(Poly* poly);
enum STATUS Calcul_Fonction(Poly* poly, float x, float *out); enum STATUS Calcul_Fonction(Poly* poly, float x, float *out);
enum STATUS Calcul_Derivee(Poly* poly, float x, float *out); enum STATUS Calcul_Derivee(Poly* poly, float x, float *out);
#define LONGUEUR_X 20 int LONGUEUR_X = 20;
#define LONGUEUR_Y 20 int LONGUEUR_Y = 20;
void Dessiner_Separateur(); void Dessiner_Separateur();
bool use_colors = false; int use_colors = false;
enum STATUS Dessiner_Graph(Poly* poly); enum STATUS Dessiner_Graph(Poly* poly);
int main(); int main();