3 <style|<tuple|book|style-bk>>
9 <assign|description-aligned|<\macro|body>
10 <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>>
18 <\description-compact>
19 <item*|assignment>An expression in which a variable is set to a value.
20 For example, in the expression <hgroup|<cpp|x = 1>>, the variable <cpp|x>
21 is set to the value <cpp|1> because <cpp|x> is to the left of the equals
22 sign \ \P<cpp|=>\Q. The value of the entire expression is equal to the
23 value of the left hand side (i.e. <cpp|x> in this example) after the
24 assignment is performed. For example, the following C code will print
28 #include \<less\>stdio.h\<gtr\>
34 \ \ if( (c = 7) == 7 )
36 \ \ \ \ printf("true");
40 \ \ \ \ printf("false");
45 As another example, the following lines are equivalent:
50 a = ( b = ( c = 0 ) );
53 <item*|declaration<label|term declaration>>A construct that establishes
54 an association between a particular variable, function, or type and its
55 attributes. (See <hlink|cppreference.com|https://en.cppreference.com/w/c/language/declarations>
56 and <hlink|microsoft.com|https://docs.microsoft.com/en-us/cpp/c-language/c-declarations-and-definitions>).
57 Compare with <with|font-series|bold|definition>.
59 <item*|definition<label|term definition>>A construct that stablishes the
60 same associations as a declaration but also causes storage to be
61 allocated for the variable. (See <hlink|microsoft.com|https://docs.microsoft.com/en-us/cpp/c-language/c-declarations-and-definitions>).
63 <item*|enumeration<label|term enumeration>><hlink|Enumeration|https://en.wikipedia.org/wiki/Enumeration>
64 (or <code*|enum>) is a user defined data type in <name|C>. It is mainly
65 used to assign names to integral constants. For example, the declaration
66 <code*|enum year{Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov,
67 Dec};> allows writing a for loop with names of months <code*|for (i=Jan;
68 i\<less\>=Dec; i++)> to cycle <code*|i> through the integers <code*|0, 1,
69 2, 3, <text-dots>, 10, 11>.
71 <item*|escape sequence<label|term escape_sequence>>A set of characters
72 used to represent hard-to-type or invisible characters. Some commonly
73 used escape sequences in <name|C> include:
75 <\description-aligned>
76 <item*|<cpp|\\n>>Represents the <em|newline> character.
78 <item*|<cpp|\\t>>Represents the <em|tab> character.
80 <item*|<cpp|\\b>>Represents the <em|backspace> character.
82 <item*|<cpp|\\\\>>Represents the <em|backslash> (i.e.
83 \P<verbatim|<em|\\>>\Q) character.
84 </description-aligned>
86 All other escape sequences used in <name|C> are:
88 <\description-aligned>
89 <item*|<cpp|\\a>>Represents the <em|alert> (bell) character.
91 <item*|<cpp|\\f>>Represents the <em|formfeed> character.
93 <item*|<cpp|\\r>>Represents the <em|carriage return> character.
95 <item*|<cpp|\\t>>Represents the <em|horizontal tab> character.
97 <item*|<cpp|\\v>>Represents the <em|vertical tab> character.
99 <item*|<cpp|\\?>>Represents the <em|question mark> character.
101 <item*|<cpp|\\'>>Represents the <em|single quote> character.
103 <item*|<cpp|\\">>Represents the <em|double quote> character.
105 <item*|<cpp|\\><em|ooo>>Represents an <em|octal number> (e.g.
106 <cpp|\\012> is the <em|newline> character<\footnote>
107 <label|ref includehelp-oct-hex>See
108 <hlinkv|https://www.includehelp.com/c/octal-and-hexadecimal-escape-sequences.aspx>.
111 <item*|<cpp|\\x><em|hh>>Represents a <em|hexadecimal> number (e.g.
112 <cpp|\\x0A> is the <em|newline> character<rsup|<reference|ref
113 includehelp-oct-hex>>).
114 </description-aligned>
116 <label|term garbage_collection><item*|garbage collection>The process of
117 freeing memory allocated by a program but which is no longer referenced.
118 Usually incurs a significant <hlink|speed
119 penalty|https://en.wikipedia.org/wiki/Overhead_(computing)>.
120 (<hlink|Wikipedia|https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)>).
121 The <name|C> Language does not provide garbage collection by default.
123 <item*|<label|term heap>heap>A large pool of memory that can be used
124 dynamically \U it is also known as the \Pfree store\Q. This is memory
125 that is not automatically managed \U you have to explicitly allocate
126 (using functions such as malloc), and deallocate (e.g. free) the memory.
127 Failure to free the memory when you are finished with it will result in
128 what is known as a memory leak. Is the diametrical opposite of the stack
129 (which, by contrast, is limited not by physical memory but by a
130 CPU-determined stack size). (See <hlink|craftofcoding.wordpress.com|https://craftofcoding.wordpress.com/2015/12/07/memory-in-c-the-stack-the-heap-and-static/>).
132 <item*|<label|term machine-independent>machine-independent>A property of
133 code that does not have to be modified in order to run on a different
134 hardware architecture. (e.g. \PC is called a portable language because
135 [code written in C] will run on any machine which supports C, without
136 modifying a single line of code.\Q; <hlink|link|https://www.log2base2.com/C/basic/introduction-to-c-language.html>).
138 <item*|<label|term operand>operand>A quantity to which an operator is
139 applied. (e.g. in the <name|C> math expression <code*|7 - 4 = 3>,
140 <code*|7> is the first operand and <code*|4> is the second operand.)
142 <item*|<label|term operator>operator>A special type of function with
143 limited numbers of parameters (e.g. 1 to 2) and syntax often requiring a
144 set of characters different from those normally use for naming variables
145 (e.g. the <code*|+> character in <code*|myVar = 1 + 2>, the <code*|&&> in
146 <code*|a && b>, or the <code*|++> in <code*|i++>.).
148 <item*|<label|term stack>stack>A region of memory for global variable
149 storage and is permanent for the entire run of the program. Stack size is
150 limited not by physical memory availability but by the CPU. Lifetime of
151 local variables declared within the stack is enforced by the Last-In,
152 First-Out nature of the stack; when a function returns a value, all stack
153 memory allocated by declarations within the function is automatically
154 freed. (See <hlink|craftofcoding.wordpress.com|https://craftofcoding.wordpress.com/2015/12/07/memory-in-c-the-stack-the-heap-and-static/>)
156 <item*|<label|term struct>struct>(short:
157 <hlink|struct|https://en.wikipedia.org/wiki/struct_(C_programming_language)>)
158 a <hlink|composite data type|https://en.wikipedia.org/wiki/Composite_data_type>
159 that defines a physically grouped list of variables under one name in a
160 block of memory, allowing the different variables to be accessed via a
161 single <hlink|pointer|https://en.wikipedia.org/wiki/Pointer_(computer_programming)>
162 or by the struct declared name which returns the same address.
164 <label|term structure_assignment><item*|structure assignment>The act of
165 <hlink|assigning|https://en.wikipedia.org/wiki/Assignment_(computer_science)>
166 a <hlink|struct|https://en.wikipedia.org/wiki/struct_(C_programming_language)>
167 to another struct. (?) (<hlink|example|https://stackoverflow.com/a/2302359/10850071>)
169 <item*|<label|term text_stream>text stream>A sequence of characters
170 divided into lines; each line consists of zero or more characters
171 followed by a newline character. (See K&R 2nd Ed. Section 1.5 \PCharacter
173 </description-compact>
179 <subsection|Character Input and Output>
182 <item*|<cpp|getchar()><label|func getchar>>Read one character at a time
183 from the input buffer. Returns as <cpp|int> a <em|character
184 constant>.<\footnote>
185 <name|ASCII> characters have constants in the range <math|0-127>. UTF-8
186 characters return multiple constants (e.g. \<#B0\> returns <cpp|194
187 176>). See <hlinkv|https://www.smashingmagazine.com/2012/06/all-about-unicode-utf8-character-sets/>.
188 A strategy for reading the multiple bytes of a UTF-8 character is here:
189 <hlinkv|https://stackoverflow.com/a/34240796/>.
192 <item*|<cpp|for()>>A generalization of <cpp|while()>. Takes three
196 <item>Local statement to run before loop (e.g. to initialize a counting
199 <item>Local statement that, if evaluated as true, permits running of
200 next iteration of loop.
202 <item>Local statement to run after loop (e.g. to increment a counting
206 <item*|<cpp|putchar(int arg1)><label|func putchar>>Write one integer
207 character (e.g. <cpp|arg1>) at a time.
209 <item*|<cpp|printf()>>Used for printing formatted text to console.
211 Character codes include:
213 <\description-aligned>
214 <item*|<cpp|%d>>Used with <cpp|int> (i.e. 16-bit integers; max value of
215 <math|2<rsup|16>=32\<space\>767>).
217 <item*|<cpp|%ld>>Used with <cpp|long> (i.e. at least 32-bit
218 integers).<\footnote>
219 K&R 2nd Ed., Sec. 1.5 \PThe conversion specification <cpp|%ld> tells
220 <cpp|printf> that the corresponding argument is a <cpp|long>
224 <item*|<cpp|%f>>Used with <cpp|float> and <cpp|double> (double
225 precision <cpp|float>).
226 </description-aligned>
238 <associate|preamble|false>
244 <associate|auto-1|<tuple|1|?>>
245 <associate|auto-2|<tuple|1.1|?>>
246 <associate|auto-3|<tuple|1.2|?>>
247 <associate|auto-4|<tuple|1.2.1|?>>
248 <associate|footnote-1|<tuple|1|?>>
249 <associate|footnote-1.1.1|<tuple|1.1.1|?>>
250 <associate|footnote-1.2.1|<tuple|1.2.1|?>>
251 <associate|footnote-1.2.2|<tuple|1.2.2|?>>
252 <associate|footnr-1.1.1|<tuple|1.1.1|?>>
253 <associate|footnr-1.2.1|<tuple|1.2.1|?>>
254 <associate|footnr-1.2.2|<tuple|1.2.2|?>>
255 <associate|func getchar|<tuple|1.2.1|?>>
256 <associate|func putchar|<tuple|3|?>>
257 <associate|ref includehelp-oct-hex|<tuple|1.1.1|?>>
258 <associate|term declaration|<tuple|assignment|?>>
259 <associate|term definition|<tuple|declaration<label|term declaration>|?>>
260 <associate|term enumeration|<tuple|definition<label|term definition>|?>>
261 <associate|term escape_sequence|<tuple|enumeration<label|term
263 <associate|term garbage_collection|<tuple|<with|mode|<quote|prog>|prog-language|<quote|cpp>|font-family|<quote|rm>|\\x><with|font-shape|<quote|italic>|hh>|?>>
264 <associate|term heap|<tuple|garbage collection|?>>
265 <associate|term machine-independent|<tuple|<label|term heap>heap|?>>
266 <associate|term operand|<tuple|<label|term
267 machine-independent>machine-independent|?>>
268 <associate|term operator|<tuple|<label|term operand>operand|?>>
269 <associate|term stack|<tuple|<label|term operator>operator|?>>
270 <associate|term struct|<tuple|<label|term stack>stack|?>>
271 <associate|term structure_assignment|<tuple|<label|term struct>struct|?>>
272 <associate|term text_stream|<tuple|structure assignment|?>>
279 <vspace*|1fn><with|font-series|<quote|bold>|math-font-series|<quote|bold>|1<space|2spc>Definitions>
280 <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
281 <no-break><pageref|auto-1><vspace|0.5fn>
283 1.1<space|2spc>Terminology <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
284 <no-break><pageref|auto-2>
286 1.2<space|2spc>Functions <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
287 <no-break><pageref|auto-3>
289 <with|par-left|<quote|1tab>|1.2.1<space|2spc>Character Input and Output
290 <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
291 <no-break><pageref|auto-4>>