AfanasevGad7

This is a task for our favourite professor
git clone git://git.stellar-nexus.ru/AfanasevGad7
Log | Files | Refs | README

commit 88880d15b850eec809affb5fb25d9052da839ee4
parent f0978031d8d9243564ae9338de7004c2edd89907
Author: Plat <plat@stellar-nexus.ru>
Date:   Fri,  7 Nov 2025 09:09:37 +0000

Fixed various segfaults in fib.c

Diffstat:
Mfib.c | 9+++++----
1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/fib.c b/fib.c @@ -51,7 +51,7 @@ count(Node *root) static inline void usage(void) { - eprintf("usage: %s [c | s | -c | -s] [depth]\n", argv0); + eprintf("usage: %s [-c] [-s] [depth]\n", argv0); } int @@ -69,15 +69,16 @@ main(int argc, char *argv[]) default: usage(); } ARGEND - if (argc != 2 && !(cflag || sflag)) + if (argc != 1 && !(cflag || sflag)) usage(); clock_t start_time, time = 0; if (cflag) start_time = clock(); - Node *root = create(estrtonum(argv[1], 0, UINT_MAX)); - time += clock() - start_time; + Node *root = create(estrtonum(argv[0], 0, UINT_MAX)); + if (cflag) + time += clock() - start_time; volatile unsigned long int fib = 0; /* to avoid optimization */ if (sflag) {