]> zdv2.bktei.com Git - BK-2023-05.git/commitdiff
update(src/kr):Finish section 1.5.1
authorSteven Baltakatei Sandoval <baltakatei@gmail.com>
Fri, 12 Aug 2022 22:36:02 +0000 (22:36 +0000)
committerSteven Baltakatei Sandoval <baltakatei@gmail.com>
Fri, 12 Aug 2022 22:36:02 +0000 (22:36 +0000)
src/kr_exercises/ch1/s1.4/temp_convert_symbolic_constant [new file with mode: 0755]
src/kr_exercises/ch1/s1.4/temp_convert_symbolic_constant.c [new file with mode: 0644]
src/kr_exercises/ch1/s1.5/get_put_char [new file with mode: 0755]
src/kr_exercises/ch1/s1.5/get_put_char.c [new file with mode: 0644]
src/kr_exercises/ch1/s1.5/get_put_char2 [new file with mode: 0755]
src/kr_exercises/ch1/s1.5/get_put_char2.c [new file with mode: 0644]
src/kr_exercises/ch1/s1.5/getchar_eof_test [new file with mode: 0755]
src/kr_exercises/ch1/s1.5/getchar_eof_test.c [new file with mode: 0644]
src/notes.tm
src/style-bk.ts [new file with mode: 0644]

diff --git a/src/kr_exercises/ch1/s1.4/temp_convert_symbolic_constant b/src/kr_exercises/ch1/s1.4/temp_convert_symbolic_constant
new file mode 100755 (executable)
index 0000000..37dda8f
Binary files /dev/null and b/src/kr_exercises/ch1/s1.4/temp_convert_symbolic_constant differ
diff --git a/src/kr_exercises/ch1/s1.4/temp_convert_symbolic_constant.c b/src/kr_exercises/ch1/s1.4/temp_convert_symbolic_constant.c
new file mode 100644 (file)
index 0000000..8e35a55
--- /dev/null
@@ -0,0 +1,22 @@
+/* Desc: Prints Fahrenheit-Celsius table; uses symbolic constants
+ * Usage: name=temp_convert; gcc -o "$name" "$name".c; ./"$name";
+ * Ref/Attrib: [0]: The C Programming Language, 2nd Edition, Section 1.4
+ */
+#include <stdio.h>
+
+# define LOWER   0  /* Lower limit of table. */
+# define UPPER 300  /* Upper limit of table. */
+# define STEP   20  /* Step size. */
+
+/* Print Fahrenheit–Celsius table */
+
+int main(){
+  int fahr;
+  for (fahr = LOWER; fahr <= UPPER; fahr = fahr + STEP)
+    printf("%3d %6.1f\n", fahr, (5.0/9.0)*(fahr - 32) );
+  return 0;
+};
+
+/* Author: Steven Baltakatei Sandoval
+ * License: GPLv3+
+ */
diff --git a/src/kr_exercises/ch1/s1.5/get_put_char b/src/kr_exercises/ch1/s1.5/get_put_char
new file mode 100755 (executable)
index 0000000..62b2796
Binary files /dev/null and b/src/kr_exercises/ch1/s1.5/get_put_char differ
diff --git a/src/kr_exercises/ch1/s1.5/get_put_char.c b/src/kr_exercises/ch1/s1.5/get_put_char.c
new file mode 100644 (file)
index 0000000..f2adec6
--- /dev/null
@@ -0,0 +1,22 @@
+/* Desc: Reads and prints inputted char
+ * Usage: name=get_put_char; gcc -o "$name" "$name".c; ./"$name";
+ * Ref/Attrib: [0]: The C Programming Language, 2nd Edition, Section 1.5.1
+ */
+#include <stdio.h>
+
+/* copy input to output; 1st version */
+
+int main(){
+  int c;
+
+  c = getchar();
+  while(c != EOF) {
+    putchar(c);
+    c = getchar();
+  };
+  return 0;
+};
+
+/* Author: Steven Baltakatei Sandoval
+ * License: GPLv3+
+ */
diff --git a/src/kr_exercises/ch1/s1.5/get_put_char2 b/src/kr_exercises/ch1/s1.5/get_put_char2
new file mode 100755 (executable)
index 0000000..1a42622
Binary files /dev/null and b/src/kr_exercises/ch1/s1.5/get_put_char2 differ
diff --git a/src/kr_exercises/ch1/s1.5/get_put_char2.c b/src/kr_exercises/ch1/s1.5/get_put_char2.c
new file mode 100644 (file)
index 0000000..8f396cc
--- /dev/null
@@ -0,0 +1,19 @@
+/* Desc: Reads and prints inputted char
+ * Usage: name=get_put_char2; gcc -o "$name" "$name".c; ./"$name";
+ * Ref/Attrib: [0]: The C Programming Language, 2nd Edition, Section 1.5.1
+ */
+#include <stdio.h>
+
+/* copy input to output; 2nd version */
+
+int main(){
+  int c;
+
+  while((c = getchar()) != EOF)
+    putchar(c);
+  return 0;
+};
+
+/* Author: Steven Baltakatei Sandoval
+ * License: GPLv3+
+ */
diff --git a/src/kr_exercises/ch1/s1.5/getchar_eof_test b/src/kr_exercises/ch1/s1.5/getchar_eof_test
new file mode 100755 (executable)
index 0000000..d859d27
Binary files /dev/null and b/src/kr_exercises/ch1/s1.5/getchar_eof_test differ
diff --git a/src/kr_exercises/ch1/s1.5/getchar_eof_test.c b/src/kr_exercises/ch1/s1.5/getchar_eof_test.c
new file mode 100644 (file)
index 0000000..3ef4f5d
--- /dev/null
@@ -0,0 +1,21 @@
+/* Desc: Test behavior of "getchar() not equal to EOF"
+ * Usage: name=getchar_eof_test; gcc -o "$name" "$name".c; ./"$name";
+ * Ref/Attrib: [0]: The C Programming Language, 2nd Edition, Section 1.5.1
+ */
+#include <stdio.h>
+
+/* Reads a single character. Will display "output:0" if first
+ *  character provided is EOF (e.g. "alt+D").  Otherwise, will display
+ *  "output:1".
+ */
+
+int main(){
+  int output;
+  output = (getchar() != EOF);
+  printf("output:%d", output);
+  return 0;
+};
+
+/* Author: Steven Baltakatei Sandoval
+ * License: GPLv3+
+ */
index c55e59ee91d37b291eb0a51d61c41002ff813e8f..67728a60631550443893e677b86f59f40359a308 100644 (file)
       variable).
     </enumerate>
 
       variable).
     </enumerate>
 
-    <item*|<cpp|putchar()><label|func putchar>>Write one character at a time.
+    <item*|<cpp|putchar(int arg1)><label|func putchar>>Write one integer
+    character (e.g. <cpp|arg1>) at a time.
 
     <item*|<cpp|printf()>>Used for printing formatted text to console.
   </description>
 
     <item*|<cpp|printf()>>Used for printing formatted text to console.
   </description>
diff --git a/src/style-bk.ts b/src/style-bk.ts
new file mode 100644 (file)
index 0000000..b4b8217
--- /dev/null
@@ -0,0 +1,108 @@
+<TeXmacs|2.1.2>
+
+<style|source>
+
+<\body>
+  <\active*>
+    <\src-title>
+      <src-package|pubkeys-book-style|0.0.1>
+
+      <src-purpose|Style package for Notable Public Keys TeXmacs source
+      files.>
+    </src-title>
+  </active*>
+
+  <use-package|number-long-article|libertine-font>
+
+  <\active*>
+    <\src-comment>
+      Style parameters.
+    </src-comment>
+  </active*>
+
+  <assign|info-flag|detailed>
+
+  <assign|page-height|auto>
+
+  <assign|page-width|auto>
+
+  <assign|page-type|a4>
+
+  <\active*>
+    <\src-comment>
+      Macro definitions.
+    </src-comment>
+  </active*>
+
+  \;
+
+  <assign|bktable3|<macro|body|<tformat|<twith|table-min-rows|2>|<twith|table-min-cols|2>|<cwith|1|1|1|-1|cell-tborder|2ln>|<cwith|1|1|1|-1|cell-bborder|1ln>|<cwith|-1|-1|1|-1|cell-bborder|2ln>|<cwith|1|-1|1|-1|cell-bsep|0.25fn>|<cwith|1|-1|1|-1|cell-tsep|0.25fn>|<cwith|1|-1|1|-1|cell-lsep|0.50fn>|<cwith|1|-1|1|-1|cell-rsep|0.50fn>|<arg|body>>>>
+
+  <assign|def|<macro|body|<hgroup|<em|<inactive|<reference|<arg|body>>>>>>>
+
+  <assign|hlinkv-delme|<macro|body|<hlink|<verbatim|<arg|body>>
+  |<arg|body>>>>
+
+  <assign|hlinkv|<macro|body|<hlink|<verbatim|<condensed|<arg|body>>>
+  |<arg|body>>>>
+
+  <assign|long-id-spc|<macro|body|<with|hmagnified-factor|0.75|color|brown|<hgroup|<hmagnified|<verbatim|<arg|body>>>>>>>
+
+  <assign|long-id|<macro|body|<with|color|brown|<hgroup|<verbatim|0x<arg|body>>>>>>
+
+  <assign|verbatim-8pt|<\macro|body>
+    <\with|font-base-size|8>
+      <\verbatim>
+        <arg|body>
+      </verbatim>
+    </with>
+  </macro>>
+
+  <assign|verb-sm|<macro|body|<with|font-base-size|8|<verbatim|<arg|body>>>>>
+
+  <assign|version|<macro|body|<em|v<arg|body>>>>
+
+  <assign|vpk|<\macro|body>
+    <\vgroup>
+      <\verbatim-8pt>
+        <\with|font-base-size|8>
+          <arg|body>
+        </with>
+      </verbatim-8pt>
+    </vgroup>
+
+    \;
+  </macro>>
+
+  <\active*>
+    <\src-comment>
+      Macro definitions: Monospace code blocks
+    </src-comment>
+  </active*>
+
+  <assign|code-wide|<\macro|body>
+    <\wide-block>
+      <tformat|<cwith|1|1|1|1|cell-background|pastel
+      cyan>|<table|<row|<\cell>
+        <\shell-code>
+          <arg|body>
+        </shell-code>
+      </cell>>>>
+    </wide-block>
+  </macro>>
+
+  <assign|code-wide-sm|<\macro|body>
+    <with|font|Linux Libertine|font-base-size|8|<\code-wide>
+      <arg|body>
+    </code-wide>>
+  </macro>>
+
+  <assign|code-inline|<macro|body|<tabular|<tformat|<cwith|1|1|1|1|cell-background|pastel
+  cyan>|<cwith|1|1|1|1|cell-tborder|1ln>|<cwith|1|1|1|1|cell-bborder|1ln>|<cwith|1|1|1|1|cell-lborder|1ln>|<cwith|1|1|1|1|cell-rborder|1ln>|<table|<row|<cell|<verbatim|<arg|body>>>>>>>>>
+</body>
+
+<\initial>
+  <\collection>
+    <associate|preamble|true>
+  </collection>
+</initial>
\ No newline at end of file