]> zdv2.bktei.com Git - BK-2023-05.git/blobdiff - src/notes.tm
feat(src/kr/s1.5):Add more examples
[BK-2023-05.git] / src / notes.tm
index 67728a60631550443893e677b86f59f40359a308..884ee8cd24c54322bbc17056f582f626670129b8 100644 (file)
@@ -3,6 +3,14 @@
 <style|<tuple|book|style-bk>>
 
 <\body>
+  <\hide-preamble>
+    \;
+
+    <assign|description-aligned|<\macro|body>
+      <compound|<if|<and|<value|<merge|prefix-|description-aligned>>|<unequal|<value|last-item-nr>|0>>|list*|list>|<macro|name|<aligned-item|<item-strong|<arg|name><item-spc>>>>|<macro|name|<with|mode|math|<with|font-series|bold|math-font-series|bold|<rigid|\<ast\>>>>>|<arg|body>>
+    </macro>>
+  </hide-preamble>
+
   <chapter|Definitions>
 
   <section|Terminology>
@@ -30,7 +38,7 @@
     used to represent hard-to-type or invisible characters. Some commonly
     used escape sequences in <name|C> include:
 
-    <\description-paragraphs>
+    <\description-aligned>
       <item*|<cpp|\\n>>Represents the <em|newline> character.
 
       <item*|<cpp|\\t>>Represents the <em|tab> character.
 
       <item*|<cpp|\\\\>>Represents the <em|backslash> (i.e.
       \P<verbatim|<em|\\>>\Q) character.
-    </description-paragraphs>
+    </description-aligned>
 
     All other escape sequences used in <name|C> are:
 
-    <\description-paragraphs>
+    <\description-aligned>
       <item*|<cpp|\\a>>Represents the <em|alert> (bell) character.
 
       <item*|<cpp|\\f>>Represents the <em|formfeed> character.
@@ -69,7 +77,7 @@
       <item*|<cpp|\\x><em|hh>>Represents a <em|hexadecimal> number (e.g.
       <cpp|\\x0A> is the <em|newline> character<rsup|<reference|ref
       includehelp-oct-hex>>).
-    </description-paragraphs>
+    </description-aligned>
 
     <label|term garbage_collection><item*|garbage collection>The process of
     freeing memory allocated by a program but which is no longer referenced.
   <subsection|Character Input and Output>
 
   <\description>
-    <item*|<cpp|getchar()><label|func getchar>>Read one character at a time.
+    <item*|<cpp|getchar()><label|func getchar>>Read one character at a time
+    from the input buffer. Returns as <cpp|int> a <em|character
+    constant>.<\footnote>
+      <name|ASCII> characters have constants in the range <math|0-127>. UTF-8
+      characters return multiple constants (e.g. \<#B0\> returns <cpp|194
+      176>). See <hlinkv|https://www.smashingmagazine.com/2012/06/all-about-unicode-utf8-character-sets/>.
+      A strategy for reading the multiple bytes of a UTF-8 character is here:
+      <hlinkv|https://stackoverflow.com/a/34240796/>.
+    </footnote>
 
     <item*|<cpp|for()>>A generalization of <cpp|while()>. Takes three
     arguments:
     character (e.g. <cpp|arg1>) at a time.
 
     <item*|<cpp|printf()>>Used for printing formatted text to console.
+
+    Character codes include:
+
+    <\description-aligned>
+      <item*|<cpp|%d>>Used with <cpp|int> (i.e. 16-bit integers; max value of
+      <math|2<rsup|16>=32\<space\>767>).
+
+      <item*|<cpp|%ld>>Used with <cpp|long> (i.e. at least 32-bit
+      integers).<\footnote>
+        K&R 2nd Ed., Sec. 1.5 \PThe conversion specification <cpp|%ld> tells
+        <cpp|printf> that the corresponding argument is a <cpp|long>
+        integer.\Q
+      </footnote>
+
+      <item*|<cpp|%f>>Used with <cpp|float> and <cpp|double> (double
+      precision <cpp|float>).
+    </description-aligned>
   </description>
 
   \;
     <associate|auto-2|<tuple|1.1|?>>
     <associate|auto-3|<tuple|1.2|?>>
     <associate|auto-4|<tuple|1.2.1|?>>
+    <associate|footnote-1|<tuple|1|?>>
     <associate|footnote-1.1.1|<tuple|1.1.1|?>>
-    <associate|footnote-1.1.2|<tuple|1.1.2|?>>
+    <associate|footnote-1.2.1|<tuple|1.2.1|?>>
+    <associate|footnote-1.2.2|<tuple|1.2.2|?>>
     <associate|footnr-1.1.1|<tuple|1.1.1|?>>
-    <associate|footnr-1.1.2|<tuple|1.1.2|?>>
+    <associate|footnr-1.2.1|<tuple|1.2.1|?>>
+    <associate|footnr-1.2.2|<tuple|1.2.2|?>>
     <associate|func getchar|<tuple|1.2.1|?>>
     <associate|func putchar|<tuple|3|?>>
     <associate|ref includehelp-oct-hex|<tuple|1.1.1|?>>
     <associate|term enumeration|<tuple|definition<label|term definition>|?>>
     <associate|term escape_sequence|<tuple|enumeration<label|term
     enumeration>|?>>
-    <associate|term foo|<tuple|structure assignment|?>>
-    <associate|term garbage_collection|<tuple|1.1.1|?>>
+    <associate|term garbage_collection|<tuple|<with|mode|<quote|prog>|prog-language|<quote|cpp>|font-family|<quote|rm>|\\x><with|font-shape|<quote|italic>|hh>|?>>
     <associate|term heap|<tuple|garbage collection|?>>
     <associate|term machine-independent|<tuple|<label|term heap>heap|?>>
     <associate|term operand|<tuple|<label|term
     <associate|term struct|<tuple|<label|term stack>stack|?>>
     <associate|term structure_assignment|<tuple|<label|term struct>struct|?>>
     <associate|term text_stream|<tuple|structure assignment|?>>
-    <associate|term-sep XX|<tuple|structure assignment|?>>
   </collection>
 </references>