aboutsummaryrefslogtreecommitdiffstats
path: root/main_23.c
diff options
context:
space:
mode:
authorjustanothercatgirl <sotov@twistea.su>2024-09-26 12:58:48 +0300
committerjustanothercatgirl <sotov@twistea.su>2024-09-26 12:58:48 +0300
commit824d6b53b27e742cf8ca04380f30ca30f5b5b65f (patch)
tree5c56a3965b618f00d1e5145afebe84f92b4f5707 /main_23.c
parenta9bd52226fbcac98bddec9cffcef1ded8b75b5df (diff)
added quiet flagtask3
Diffstat (limited to 'main_23.c')
-rw-r--r--main_23.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/main_23.c b/main_23.c
index 8460415..256611e 100644
--- a/main_23.c
+++ b/main_23.c
@@ -135,6 +135,7 @@ int main(int argc, char *argv[]) {
func_t function = NULL;
const char *out = NULL;
char task2 = 1;
+ char verbose = 1;
float dx = 0.0;
// casual argument loop
for (int i = 1; i < argc; ++i) {
@@ -148,6 +149,8 @@ int main(int argc, char *argv[]) {
task2 = 0;
else if (!strcmp(argv[i], "-x"))
dx = atof(argv[++i]);
+ else if (!strcmp(argv[i], "-q"))
+ verbose = 0;
else print_help(EXIT_FAILURE);
}
// if function or output file is not set, or if dx is not set for task3,
@@ -163,7 +166,8 @@ int main(int argc, char *argv[]) {
table = differentiate(function, -3, 3, dx, &table_len);
// print data to stdout and to file
- print_table(stdout, table, table_len);
+
+ if (verbose) print_table(stdout, table, table_len);
FILE *f = fopen(out, "w+");
if (f) print_table(f, table, table_len);
else perror(out);