c-first-steps

a C playground
Index Commits Files Refs README
commit c9bc9bbc69486fb6ffe1f2753ed9829104f4509d
parent 96aa683696357921383a14cb3686f7ad58b6b81c
Author: Martin J. Klöckner <martin.cachari@gmail.com>
Date:   Wed, 25 Nov 2020 23:40:26 -0300

Added ex22.c

Diffstat:
A95.11/guia03/ex22.c | 20++++++++++++++++++++
1 file changed, 20 insertions(+), 0 deletions(-)
diff --git a/95.11/guia03/ex22.c b/95.11/guia03/ex22.c
@@ -0,0 +1,20 @@
+#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;
+
+    num = atoi(buffer);
+    sprintf(num2, "%d\n", num);
+
+    printf("%s", num2);
+    return 0;
+}