diff options
author | Daniel Santos <dacs.git@brilhante.top> | 2022-03-08 22:33:57 +0000 |
---|---|---|
committer | Daniel Santos <dacs.git@brilhante.top> | 2022-03-09 12:34:32 +0000 |
commit | ef7e6f99a265339336bf02305f9d25cfedbf04e7 (patch) | |
tree | e90fe0a76560bb15831ad16c814ec4aaeb93775d | |
parent | 6715048969978af4f6b332f0259ed8f81fdd7319 (diff) | |
download | numericx-c-ef7e6f99a265339336bf02305f9d25cfedbf04e7.tar.gz |
add argument processing
add usage message when invalid argument Signed-off-by: Daniel Santos <dacs.git@brilhante.top>
-rw-r--r-- | numericx.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/numericx.c b/numericx.c index 792a4c3..87cde70 100644 --- a/numericx.c +++ b/numericx.c @@ -97,6 +97,13 @@ main(int argc, char* argv[]) { program_name = argv[0]; + /* argument processing */ + if( !(argc == 2) ) + { + fprintf(stderr, "usage: %s <number>\n", program_name); + exit(EXIT_FAILURE); + } + /* Numeral System variables from MACROS */ char* from = malloc( (strlen(FROM_NUMERICALS) + 1) * sizeof(char) ); char* to = malloc( (strlen(TO_NUMERICALS) + 1) * sizeof(char) ); |