c-first-steps

a C playground
Index Commits Files Refs README
commit 6770d7ce8e4b3e0d319c340fb149c69b1fce1316
parent 6c445c8f075c7749231cd5a83488606fe4f69ffc
Author: Martin J. Klöckner <martin.cachari@gmail.com>
Date:   Sat, 21 Nov 2020 01:55:43 -0300

Renamed src/

Diffstat:
Athe-c-programming-language/chapter01/ex1-1.c | 10++++++++++
Athe-c-programming-language/chapter01/ex1-8.c | 24++++++++++++++++++++++++
Athe-c-programming-language/chapter01/ex1-9.c | 20++++++++++++++++++++
Rsrc/dc.c -> the-c-programming-language/dc.c | 0
Rsrc/factorial.c -> the-c-programming-language/factorial.c | 0
Rsrc/ftoc.c -> the-c-programming-language/ftoc.c | 0
Rsrc/helloworld.c -> the-c-programming-language/helloworld.c | 0
Rsrc/lwc.c -> the-c-programming-language/lwc.c | 0
8 files changed, 54 insertions(+), 0 deletions(-)
diff --git a/the-c-programming-language/chapter01/ex1-1.c b/the-c-programming-language/chapter01/ex1-1.c
@@ -0,0 +1,10 @@
+//    Exercise 1-1, Run the "hello, world" program.
+
+#include <stdio.h>
+
+int main( void ) {
+
+    printf("Hello, world\n");
+
+    return 0;
+}
diff --git a/the-c-programming-language/chapter01/ex1-8.c b/the-c-programming-language/chapter01/ex1-8.c
@@ -0,0 +1,24 @@
+
+
+
+#include <stdio.h>
+
+
+int main( void ) {
+
+    
+    int c, bl, tb, nl;
+    bl = tb = nl = 0;
+
+    while((c = getchar()) != EOF) {
+        if (c == ' ') 
+            bl++;
+        else if (c == '\t') 
+            tb++;
+        else if (c == '\n')
+            nl++;
+    }
+
+    printf("Blanks\t\t=\t%d\nTabs\t\t=\t%d\nNewlines\t=\t%d\n", bl, tb, nl);
+    return 0;
+}
diff --git a/the-c-programming-language/chapter01/ex1-9.c b/the-c-programming-language/chapter01/ex1-9.c
@@ -0,0 +1,20 @@
+//    Exercise 1-rite a program to copy its input to its output, replacing
+//    each string of one or more blanks by a single blank.
+
+#include <stdio.h>
+
+int main( void ) {
+
+    
+    unsigned long bl;
+    bl = 0;
+
+    char aux;
+    while((aux = getchar()) != EOF) {
+        if (aux != ' ') {
+            bl = 0;
+        } else 
+            b++;
+    }
+    return 0;
+}
diff --git a/src/dc.c b/the-c-programming-language/dc.c
diff --git a/src/factorial.c b/the-c-programming-language/factorial.c
diff --git a/src/ftoc.c b/the-c-programming-language/ftoc.c
diff --git a/src/helloworld.c b/the-c-programming-language/helloworld.c
diff --git a/src/lwc.c b/the-c-programming-language/lwc.c