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*|argument<label|term_argument>>A value used to supply a
20 <strong|parameter> in the call of a <strong|function>. Also known as an
21 \Pactual argument\Q as opposed to \Pformal argument\Q (i.e.
22 <strong|parameter>). See also <em|parameter>.
24 <item*|assignment>An expression in which a variable is set to a value.
25 For example, in the expression <hgroup|<cpp|x = 1>>, the variable <cpp|x>
26 is set to the value <cpp|1> because <cpp|x> is to the left of the equals
27 sign \ \P<cpp|=>\Q. The value of the entire expression is equal to the
28 value of the left hand side (i.e. <cpp|x> in this example) after the
29 assignment is performed. For example, the following C code will print
33 #include \<less\>stdio.h\<gtr\>
39 \ \ if( (c = 7) == 7 )
41 \ \ \ \ printf("true");
45 \ \ \ \ printf("false");
50 As another example, the following lines are equivalent:
55 a = ( b = ( c = 0 ) );
58 <label|term_call><item*|call>The act of running (or \Pinvoking\Q) a
59 <strong|function>. See <em|function call>.
61 <label|term declaration><item*|declaration>A construct that establishes
62 an association between a particular variable, function, or type and its
64 See <hlinkv|https://en.cppreference.com/w/c/language/declarations>.
65 </footnote>. Announces the properties of variables. May be a statement
66 consisting of a <strong|type> name followed by a list of
67 <strong|variables> (e.g. <cpp|int i, j;>) or followed by an expression
68 with a variable (e.g. <cpp|int i = 0;>). Compare with
69 <with|font-series|bold|definition>.
71 <label|term definition><item*|definition>A construct that establishes the
72 same associations as a declaration but also causes storage to be
73 allocated for the variable<\footnote>
74 See <hlinkv|https://docs.microsoft.com/en-us/cpp/c-language/c-declarations-and-definitions?view=msvc-170>.
77 <label|term_linter><item*|linter> A source code analysis program designed
78 to detect common syntactic errors.
80 <label|term enumeration><item*|enumeration><hlink|Enumeration|https://en.wikipedia.org/wiki/Enumeration>
81 (or <code*|enum>) is a user defined data type in <name|C>. It is mainly
82 used to assign names to integral constants. For example, the declaration
83 <code*|enum year{Jan, Feb, Mar, Apr, May, Jun, Jul, Aug, Sep, Oct, Nov,
84 Dec};> allows writing a for loop with names of months <code*|for (i=Jan;
85 i\<less\>=Dec; i++)> to cycle <code*|i> through the integers <code*|0, 1,
86 2, 3, <text-dots>, 10, 11>.
88 <label|term escape_sequence><item*|escape sequence>A set of characters
89 used to represent hard-to-type or invisible characters. Some commonly
90 used escape sequences in <name|C> include:
92 <\description-aligned>
93 <item*|<cpp|\\n>>Represents the <em|newline> character.
95 <item*|<cpp|\\t>>Represents the <em|tab> character.
97 <item*|<cpp|\\b>>Represents the <em|backspace> character.
99 <item*|<cpp|\\\\>>Represents the <em|backslash> (i.e.
100 \P<verbatim|<em|\\>>\Q) character.
101 </description-aligned>
103 All other escape sequences used in <name|C> are:
105 <\description-aligned>
106 <item*|<cpp|\\a>>Represents the <em|alert> (bell) character.
108 <item*|<cpp|\\f>>Represents the <em|formfeed> character.
110 <item*|<cpp|\\r>>Represents the <em|carriage return> character.
112 <item*|<cpp|\\t>>Represents the <em|horizontal tab> character.
114 <item*|<cpp|\\v>>Represents the <em|vertical tab> character.
116 <item*|<cpp|\\?>>Represents the <em|question mark> character.
118 <item*|<cpp|\\'>>Represents the <em|single quote> character.
120 <item*|<cpp|\\">>Represents the <em|double quote> character.
122 <item*|<cpp|\\><em|ooo>>Represents an <em|octal number> (e.g.
123 <cpp|\\012> is the <em|newline> character<\footnote>
124 <label|ref includehelp-oct-hex>See
125 <hlinkv|https://www.includehelp.com/c/octal-and-hexadecimal-escape-sequences.aspx>.
128 <item*|<cpp|\\x><em|hh>>Represents a <em|hexadecimal> number (e.g.
129 <cpp|\\x0A> is the <em|newline> character<rsup|<reference|ref
130 includehelp-oct-hex>>).
131 </description-aligned>
133 <label|term_expression><item*|expression> A sequence of
134 <strong|operators> and <strong|operands> that specify a computation. When
135 evaluated, an expression may perform useful side effects (e.g.
136 <cpp|printf("%d", 4)> sends the character <cpp|4> to \ the standard
137 output stream)<\footnote>
138 See <hlinkv|https://en.cppreference.com/w/c/language/expressions>.
141 Arrangements of expressions may include<\footnote>
142 See <hlinkv|https://www.educative.io/answers/what-are-expressions-in-c>.
146 <item*|Constant>A value with no operator is used<\footnote>
147 See <hlinkv|https://www.cs.miami.edu/home/burt/learning/Math120.1/Notes/exp-syn.html>.
148 </footnote>. (e.g. the \P<cpp|0>\Q in <cpp|return 0;>)
150 <item*|Variable identifier>A variable evaluated earlier. (e.g. the 2nd
151 \P<cpp|k>\Q in <hgroup|<cpp|k = 1; return k;>>)
153 <item*|Infix expression>Operator is used between operands. (e.g. <cpp|a
156 <item*|Postfix expression>Operator is used after the operands. (e.g.
159 <item*|Prefix expression>Operator is used before the operands. (e.g.
162 <item*|Unary expression>There is one operator and one operand. (e.g.
165 <item*|Binary expression>There is one operator and two operands. (e.g.
169 Types of expressions may include:
172 <item*|Arithmetic expression>Consists of arithmetic operators (<cpp|+,
173 -, *, and />) and computes values of <cpp|int, float, or double> type.
175 <item*|Relational expression>Usually uses comparison operators
176 (<cpp|\<gtr\>, \<less\>, \<gtr\>=, \<less\>=, ===, and !==>) and
177 computers answer in the <cpp|bool> type (i.e. true \P<cpp|1>\Q or false
180 <item*|Logical expression>Consists of logical operators (<cpp|&&, \|\|,
181 and !>) and combines relational expressions to compute answers in the
184 <item*|Conditional expression>Consists of statements that return
185 <cpp|true> if the condition is met or <cpp|false> otherwise.
187 <item*|Pointer expression>May consist of an ampersand (<cpp|&>)
188 operator and returns <cpp|address> values.
190 <item*|Bitwise expression>Consists of bitwise operators
191 (<cpp|\<gtr\>\<gtr\>, \<less\>\<less\>, ~, &, \|, and ^>) and performs
192 operations at the bit level.
194 <item*|Constant expression>Involves only constants such that the
195 expression may be evaluated during compilation rather than
197 K&R 2nd Ed., Sec. 2.3 \PConstants\Q.
201 <label|term_function><item*|function>A group of statements that perform a
202 task. Is defined using a function <strong|definition> that has a
203 parenthesized list of <strong|declarations> called <strong|parameters>
204 (e.g. variables for accepting values named <strong|arguments> as input
205 when the <strong|function> is called). A function definition has the
209 return-type<space|1em>function-name(parameter declarations, if any) {
211 <space|1em>declarations
213 <space|1em>statements
218 <label|term_function_call><item*|function call>An expression containing
219 the <strong|function> name followed by the function call operator
222 <label|term_function_prototype><item*|function prototype>A declaration of
223 a <strong|function> consisting only of the function name (a.k.a.
224 \Pidentifier\Q) and parenthesized <strong|parameter> types so the
225 compiler knows how to perform <strong|type>-based conversions of
226 <strong|arguments> (e.g. truncating a <cpp|float> into an <cpp|int>) in
227 <strong|calls> of the function before the compiler knows the function
228 <strong|definition><\footnote>
229 See <hlinkv|https://en.cppreference.com/w/c/language/function_declaration>.
230 </footnote>. The function prototype parameter names do not have to agree
231 with the function definition parameter names<\footnote>
232 K&R 2nd Ed., Sec 1.7 \PFunctions\Q.
235 <label|term garbage_collection><item*|garbage collection>The process of
236 freeing memory allocated by a program but which is no longer referenced.
237 Usually incurs a significant <hlink|speed
238 penalty|https://en.wikipedia.org/wiki/Overhead_(computing)>.
239 (<hlink|Wikipedia|https://en.wikipedia.org/wiki/Garbage_collection_(computer_science)>).
240 The <name|C> Language does not provide garbage collection by default.
242 <item*|<label|term heap>heap>A large pool of memory that can be used
243 dynamically \U it is also known as the \Pfree store\Q. This is memory
244 that is not automatically managed \U you have to explicitly allocate
245 (using functions such as malloc), and deallocate (e.g. free) the memory.
246 Failure to free the memory when you are finished with it will result in
247 what is known as a memory leak. Is the diametrical opposite of the stack
248 (which, by contrast, is limited not by physical memory but by a
249 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/>).
251 <item*|<label|term machine-independent>machine-independent>A property of
252 code that does not have to be modified in order to run on a different
253 hardware architecture. (e.g. \PC is called a portable language because
254 [code written in C] will run on any machine which supports C, without
255 modifying a single line of code.\Q; <hlink|link|https://www.log2base2.com/C/basic/introduction-to-c-language.html>).
257 <item*|<label|term operand>operand>A quantity to which an operator is
258 applied. (e.g. in the <name|C> math expression <code*|7 - 4 = 3>,
259 <code*|7> is the first operand and <code*|4> is the second operand.)
261 <item*|<label|term operator>operator>A special type of function with
262 limited numbers of parameters (e.g. 1 to 2) and syntax often requiring a
263 set of characters different from those normally use for naming variables
264 (e.g. the <code*|+> character in <code*|myVar = 1 + 2>, the <code*|&&> in
265 <code*|a && b>, or the <code*|++> in <code*|i++>.).
267 <label|term_parameter><item*|parameter>Generally, a variable named in the
268 parenthesized list in a <strong|function> definition. Also known as a
269 \Pformal argument\Q as opposed to an \Pactual argument\Q (e.g.
270 <strong|argument>). See <em|argument>.
272 <item*|<label|term stack>stack>A region of memory for global variable
273 storage and is permanent for the entire run of the program. Stack size is
274 limited not by physical memory availability but by the CPU. Lifetime of
275 local variables declared within the stack is enforced by the Last-In,
276 First-Out nature of the stack; when a function returns a value, all stack
277 memory allocated by declarations within the function is automatically
278 freed. (See <hlink|craftofcoding.wordpress.com|https://craftofcoding.wordpress.com/2015/12/07/memory-in-c-the-stack-the-heap-and-static/>)
280 <label|term_statement><item*|statement>An <strong|expression> when it is
281 followed by a semicolon. May be grouped together using braces (i.e.
282 \P<cpp|{ }>\Q) to form a <em|compound statement> or <em|block> which is
283 syntactically equivalent to a single <strong|statement>.<\footnote>
284 K&R 2nd Ed., Sec. 3.1 \PStatements and Blocks\Q.
287 <item*|<label|term struct>struct>(short:
288 <hlink|struct|https://en.wikipedia.org/wiki/struct_(C_programming_language)>)
289 a <hlink|composite data type|https://en.wikipedia.org/wiki/Composite_data_type>
290 that defines a physically grouped list of variables under one name in a
291 block of memory, allowing the different variables to be accessed via a
292 single <hlink|pointer|https://en.wikipedia.org/wiki/Pointer_(computer_programming)>
293 or by the struct declared name which returns the same address.
295 <label|term structure_assignment><item*|structure assignment>The act of
296 <hlink|assigning|https://en.wikipedia.org/wiki/Assignment_(computer_science)>
297 a <hlink|struct|https://en.wikipedia.org/wiki/struct_(C_programming_language)>
298 to another struct. (?) (<hlink|example|https://stackoverflow.com/a/2302359/10850071>)
300 <item*|<label|term text_stream>text stream>A sequence of characters
301 divided into lines; each line consists of zero or more characters
302 followed by a newline character. (See K&R 2nd Ed. Section 1.5 \PCharacter
305 <label|term_type><item*|type>A way of differentiating data stored for use
306 in a program. Some types include <cpp|int> (integers), <cpp|char>
307 (single-byte characters), <cpp|short> (a short integer), <cpp|long> (a
308 long integer), <cpp|double> (a double-precision floating point number).
309 </description-compact>
315 <subsection|Character Input and Output>
318 <item*|<cpp|getchar()><label|func getchar>>Read one character at a time
319 from the input buffer. Returns as <cpp|int> a <em|character
320 constant>.<\footnote>
321 <name|ASCII> characters have constants in the range <math|0-127>. UTF-8
322 characters return multiple constants (e.g. \<#B0\> returns <cpp|194
323 176>). See <hlinkv|https://www.smashingmagazine.com/2012/06/all-about-unicode-utf8-character-sets/>.
324 A strategy for reading the multiple bytes of a UTF-8 character is here:
325 <hlinkv|https://stackoverflow.com/a/34240796/>.
328 <item*|<cpp|for()>>A generalization of <cpp|while()>. Takes three
332 <item>Local statement to run before loop (e.g. to initialize a counting
335 <item>Local statement that, if evaluated as true, permits running of
336 next iteration of loop.
338 <item>Local statement to run after loop (e.g. to increment a counting
342 <item*|<cpp|putchar(int arg1)><label|func putchar>>Write one integer
343 character (e.g. <cpp|arg1>) at a time.
345 <item*|<cpp|printf()>>Used for printing formatted text to console.
347 Character codes include:
349 <\description-aligned>
350 <item*|<cpp|%c>>Used to display a character by its <cpp|int>.
352 <item*|<cpp|%d>>Used with <cpp|int> (i.e. 16-bit integers; max value of
353 <math|2<rsup|16>=32\<space\>767>).
355 <item*|<cpp|%ld>>Used with <cpp|long> (i.e. at least 32-bit
356 integers).<\footnote>
357 K&R 2nd Ed., Sec. 1.5 \PThe conversion specification <cpp|%ld> tells
358 <cpp|printf> that the corresponding argument is a <cpp|long>
362 <item*|<cpp|%f>>Used with <cpp|float> and <cpp|double> (double
363 precision <cpp|float>).
364 </description-aligned>
366 For printing <name|UTF-8> strings (which are multibyte in contrast to
367 one-byte <name|ASCII> strings), functions from the C standard library
368 <cpp|wchar.h> header file<\footnote>
369 See <hlinkv|https://en.wikibooks.org/wiki/C_Programming/wchar.h>.
370 </footnote> may need to be<\footnote>
371 See <hlinkv|https://linuxprograms.wordpress.com/tag/c-utf-8-handling/>.
372 </footnote> used<\footnote>
373 See <hlinkv|https://stackoverflow.com/questions/56756204/compatibility-of-printf-with-utf-8-encoded-strings>.
374 </footnote> (e.g. <cpp|wprintf()> (?)).
381 <section|Text Editor>
384 <item><name|Emacs> - GNU text editor. See
385 <hlinkv|https://www.gnu.org/software/emacs/>.
387 <item><name|Vim> - text editor See <hlinkv|https://www.vim.org/>.
392 (TODO: Insert C language linter here)
399 <associate|preamble|false>
405 <associate|auto-1|<tuple|1|?>>
406 <associate|auto-2|<tuple|1.1|?>>
407 <associate|auto-3|<tuple|1.2|?>>
408 <associate|auto-4|<tuple|1.2.1|?>>
409 <associate|auto-5|<tuple|2|?>>
410 <associate|auto-6|<tuple|2.1|?>>
411 <associate|auto-7|<tuple|2.2|?>>
412 <associate|footnote-1.1.1|<tuple|1.1.1|?>>
413 <associate|footnote-1.1.10|<tuple|1.1.10|?>>
414 <associate|footnote-1.1.2|<tuple|1.1.2|?>>
415 <associate|footnote-1.1.3|<tuple|1.1.3|?>>
416 <associate|footnote-1.1.4|<tuple|1.1.4|?>>
417 <associate|footnote-1.1.5|<tuple|1.1.5|?>>
418 <associate|footnote-1.1.6|<tuple|1.1.6|?>>
419 <associate|footnote-1.1.7|<tuple|1.1.7|?>>
420 <associate|footnote-1.1.8|<tuple|1.1.8|?>>
421 <associate|footnote-1.1.9|<tuple|1.1.9|?>>
422 <associate|footnote-1.2.1|<tuple|1.2.1|?>>
423 <associate|footnote-1.2.2|<tuple|1.2.2|?>>
424 <associate|footnote-1.2.3|<tuple|1.2.3|?>>
425 <associate|footnote-1.2.4|<tuple|1.2.4|?>>
426 <associate|footnote-1.2.5|<tuple|1.2.5|?>>
427 <associate|footnr-1.1.1|<tuple|1.1.1|?>>
428 <associate|footnr-1.1.10|<tuple|1.1.10|?>>
429 <associate|footnr-1.1.2|<tuple|1.1.2|?>>
430 <associate|footnr-1.1.3|<tuple|1.1.3|?>>
431 <associate|footnr-1.1.4|<tuple|1.1.4|?>>
432 <associate|footnr-1.1.5|<tuple|1.1.5|?>>
433 <associate|footnr-1.1.6|<tuple|1.1.6|?>>
434 <associate|footnr-1.1.7|<tuple|1.1.7|?>>
435 <associate|footnr-1.1.8|<tuple|1.1.8|?>>
436 <associate|footnr-1.1.9|<tuple|1.1.9|?>>
437 <associate|footnr-1.2.1|<tuple|1.2.1|?>>
438 <associate|footnr-1.2.2|<tuple|1.2.2|?>>
439 <associate|footnr-1.2.3|<tuple|1.2.3|?>>
440 <associate|footnr-1.2.4|<tuple|1.2.4|?>>
441 <associate|footnr-1.2.5|<tuple|1.2.5|?>>
442 <associate|func getchar|<tuple|1.2.1|?>>
443 <associate|func putchar|<tuple|3|?>>
444 <associate|ref includehelp-oct-hex|<tuple|1.1.3|?>>
445 <associate|term declaration|<tuple|call|?>>
446 <associate|term definition|<tuple|1.1.1|?>>
447 <associate|term enumeration|<tuple|linter|?>>
448 <associate|term escape_sequence|<tuple|enumeration|?>>
449 <associate|term garbage_collection|<tuple|1.1.9|?>>
450 <associate|term heap|<tuple|garbage collection|?>>
451 <associate|term machine-independent|<tuple|<label|term heap>heap|?>>
452 <associate|term operand|<tuple|<label|term
453 machine-independent>machine-independent|?>>
454 <associate|term operator|<tuple|<label|term operand>operand|?>>
455 <associate|term stack|<tuple|parameter|?>>
456 <associate|term struct|<tuple|1.1.10|?>>
457 <associate|term structure_assignment|<tuple|<label|term struct>struct|?>>
458 <associate|term text_stream|<tuple|structure assignment|?>>
459 <associate|term_argument|<tuple|1.1|?>>
460 <associate|term_call|<tuple|assignment|?>>
461 <associate|term_delinter|<tuple|1.1.2|?>>
462 <associate|term_expression|<tuple|<with|mode|<quote|prog>|prog-language|<quote|cpp>|font-family|<quote|rm>|\\x><with|font-shape|<quote|italic>|hh>|?>>
463 <associate|term_function|<tuple|1.1.7|?>>
464 <associate|term_function_call|<tuple|function|?>>
465 <associate|term_function_prototype|<tuple|function call|?>>
466 <associate|term_linter|<tuple|1.1.2|?>>
467 <associate|term_parameter|<tuple|<label|term operator>operator|?>>
468 <associate|term_statement|<tuple|<label|term stack>stack|?>>
469 <associate|term_type|<tuple|<label|term text_stream>text stream|?>>
476 <vspace*|1fn><with|font-series|<quote|bold>|math-font-series|<quote|bold>|1<space|2spc>Definitions>
477 <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
478 <no-break><pageref|auto-1><vspace|0.5fn>
480 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>>
481 <no-break><pageref|auto-2>
483 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>>
484 <no-break><pageref|auto-3>
486 <with|par-left|<quote|1tab>|1.2.1<space|2spc>Character Input and Output
487 <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
488 <no-break><pageref|auto-4>>
490 <vspace*|1fn><with|font-series|<quote|bold>|math-font-series|<quote|bold>|2<space|2spc>Utilities>
491 <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
492 <no-break><pageref|auto-5><vspace|0.5fn>
494 2.1<space|2spc>Text Editor <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
495 <no-break><pageref|auto-6>
497 2.2<space|2spc>Linter <datoms|<macro|x|<repeat|<arg|x>|<with|font-series|medium|<with|font-size|1|<space|0.2fn>.<space|0.2fn>>>>>|<htab|5mm>>
498 <no-break><pageref|auto-7>