From c03cc73acfba7ce0dd19b6258ffee6df2020b09a Mon Sep 17 00:00:00 2001 From: Jack-Benny Persson Date: Sat, 2 May 2020 14:34:28 +0200 Subject: [PATCH] Refactoring for best practices --- Makefile | 2 +- subnetcalc.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index ac6b05b..6e1816b 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ subnetcalc: subnetcalc.c - gcc subnetcalc.c -lm -o subnetcalc + gcc -Wall -pedantic subnetcalc.c -lm -o subnetcalc clean: subnetcalc rm subnetcalc diff --git a/subnetcalc.c b/subnetcalc.c index 838157a..68135c9 100644 --- a/subnetcalc.c +++ b/subnetcalc.c @@ -6,13 +6,13 @@ #include #include -main() +int main(void) { int net; double hosts; double addr; printf("Enter netmask in slash-notation without the slash: "); - scanf("%d", &net); + scanf("%2d", &net); if (net >= 0 && net <= 32) // Sanity check the user input {