c-first-steps

a C playground
Index Commits Files Refs README
commit df83b1464032ec380b8589dc604e31d573a64259
parent 568a4c169c2b73b0e266546a2a976292c961a349
Author: Martin J. Klöckner <64109770+klewer-martin@users.noreply.github.com>
Date:   Thu, 26 Nov 2020 00:07:09 -0300

Update ex23_imp.c

Added a couple of comments
Diffstat:
M95.11/guia03/ex23_imp.c | 11+++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/95.11/guia03/ex23_imp.c b/95.11/guia03/ex23_imp.c
@@ -1,20 +1,23 @@
+//    Reads an integer from stdin and prints it
+//    on stdout in octal base; 
+
 #include <stdio.h>
 #include <stdlib.h>
 
 #define MAX_LEN 100
+#define ERR_MSG_NEG "Err: the number is negative"
 
 int main ( void ) {
 
-    char buffer[MAX_LEN];
     int num;
-    char num2[MAX_LEN];
+    char buffer[MAX_LEN];
 
     if(fgets(buffer, MAX_LEN, stdin) == NULL)
         return 1;
 
 //    Converts the input str to int;
-    if(    (num = atoi(buffer)) < 0 ) {
-        fprintf(stderr, "Debe ingresar un entero positivo!\n");
+    if((num = atoi(buffer)) < 0 ) {
+        fprintf(stderr, ERR_MSG_LEN"\n");
         return 1;
     }