c-first-steps

a C playground
Index Commits Files Refs README
commit 68efa97f64984fc3054fbfccb3229f9d45dc29ca
parent ed3d5deeede0c2b1b71ea07bec7f8022890387e1
Author: Martin J. Klöckner <martin.cachari@gmail.com>
Date:   Wed, 25 Nov 2020 23:52:33 -0300

Added ex23_beta.c, an improved version of ex23.c without the use of
sprintf() function;

Diffstat:
A95.11/guia03/ex23_beta.c | 21+++++++++++++++++++++
1 file changed, 21 insertions(+), 0 deletions(-)
diff --git a/95.11/guia03/ex23_beta.c b/95.11/guia03/ex23_beta.c
@@ -0,0 +1,21 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+#define MAX_LEN 100
+
+int main ( void ) {
+
+    char buffer[MAX_LEN];
+    int num;
+    char num2[MAX_LEN];
+
+    if(fgets(buffer, MAX_LEN, stdin) == NULL)
+        return 1;
+
+//    Converts the input str to int;
+    num = atoi(buffer);
+
+//    prints the integer in octal base;
+    printf("%o\n", num);
+    return 0;
+}