Better organize the collection of C17 notes.

main
Joshua Potter 2025-01-21 08:33:35 -07:00
parent 77e7dba1b5
commit fc5971f516
23 changed files with 3913 additions and 3520 deletions

View File

@ -373,7 +373,7 @@
"c17/strings.md": "b021b6f18f865aa89b3088907cdaae94", "c17/strings.md": "b021b6f18f865aa89b3088907cdaae94",
"c17/index.md": "78e0ebc5a91d58b297b25346a654d398", "c17/index.md": "78e0ebc5a91d58b297b25346a654d398",
"c17/escape-sequences.md": "a8b99070336878b4e8c11e9e4525a500", "c17/escape-sequences.md": "a8b99070336878b4e8c11e9e4525a500",
"c17/declarations.md": "9dbaea14e28d00704cfd0b027efe8c97", "c17/declarations.md": "d0d0b4ce2d2608dbfffa6182593eae7a",
"algorithms/sorting/merge-sort.md": "6506483f7df6507cee0407bd205dbedd", "algorithms/sorting/merge-sort.md": "6506483f7df6507cee0407bd205dbedd",
"_journal/2024-02-24.md": "9bb319d5014caf962a9ce3141076cff4", "_journal/2024-02-24.md": "9bb319d5014caf962a9ce3141076cff4",
"_journal/2024-02/2024-02-23.md": "0aad297148e8cc4058b48b7e45787ca7", "_journal/2024-02/2024-02-23.md": "0aad297148e8cc4058b48b7e45787ca7",
@ -835,7 +835,7 @@
"c17/enums.md": "9414fb67aa256a0a11b7240534c67bf6", "c17/enums.md": "9414fb67aa256a0a11b7240534c67bf6",
"c17/derived-types.md": "6fb8f23a2423f05d5bdccb6672a32e38", "c17/derived-types.md": "6fb8f23a2423f05d5bdccb6672a32e38",
"c17/basic-types.md": "7c6653bf6dc24c2f2aa72fc95c4f7875", "c17/basic-types.md": "7c6653bf6dc24c2f2aa72fc95c4f7875",
"c17/types/simple.md": "ee418366c1af73c0eea48b6cc024651f", "c17/types/simple.md": "d4b5dbc6d543f737182cb2f5cf02f2fc",
"c17/types/enumerated.md": "e1f70a30677c776b7b44ac3e0ff4e76d", "c17/types/enumerated.md": "e1f70a30677c776b7b44ac3e0ff4e76d",
"c17/types/derived.md": "fd1ecb61bed82fb6e44c170b023e5eeb", "c17/types/derived.md": "fd1ecb61bed82fb6e44c170b023e5eeb",
"c17/types/basic.md": "5064e21e683c0218890058882e06b6f3", "c17/types/basic.md": "5064e21e683c0218890058882e06b6f3",
@ -987,7 +987,7 @@
"_journal/2024-11/2024-11-21.md": "951b6034d60a40dbd8201c50abf0dbb9", "_journal/2024-11/2024-11-21.md": "951b6034d60a40dbd8201c50abf0dbb9",
"_journal/2024-11/2024-11-20.md": "951b6034d60a40dbd8201c50abf0dbb9", "_journal/2024-11/2024-11-20.md": "951b6034d60a40dbd8201c50abf0dbb9",
"_journal/2024-11/2024-11-19.md": "d879f57154cb27cb168eb1f1f430e312", "_journal/2024-11/2024-11-19.md": "d879f57154cb27cb168eb1f1f430e312",
"set/cardinality.md": "4c76186740c2ad2ae29ca9b8d9343065", "set/cardinality.md": "f927d045d2231ff59f63e59ff6dd0406",
"geometry/area.md": "7f947bb5ac782495a1fb4a63bb2463e7", "geometry/area.md": "7f947bb5ac782495a1fb4a63bb2463e7",
"_journal/2024-11-23.md": "911f82ab8aede5ecdb96493aef64b0b9", "_journal/2024-11-23.md": "911f82ab8aede5ecdb96493aef64b0b9",
"_journal/2024-11/2024-11-22.md": "51117030e2364dbce3a8d507dead86ae", "_journal/2024-11/2024-11-22.md": "51117030e2364dbce3a8d507dead86ae",
@ -1082,7 +1082,7 @@
"_journal/2024-12/2024-12-23.md": "72b0964a8a5ed8ba0acf7fe10b5de279", "_journal/2024-12/2024-12-23.md": "72b0964a8a5ed8ba0acf7fe10b5de279",
"_journal/2024-12-25.md": "1717d37b074df58175ec0272adc278de", "_journal/2024-12-25.md": "1717d37b074df58175ec0272adc278de",
"_journal/2024-12/2024-12-24.md": "dcd3bd8b82ca4d47a9642a46d8bece0d", "_journal/2024-12/2024-12-24.md": "dcd3bd8b82ca4d47a9642a46d8bece0d",
"linkers/relocatable.md": "ac24efbabe07222a89acb2fd5135cdb3", "linkers/relocatable.md": "c64223f3fdd0e17be3d73977757da52a",
"data-models/federation.md": "1d92747304186bd2833a00a488fcac48", "data-models/federation.md": "1d92747304186bd2833a00a488fcac48",
"_journal/2024-12-26.md": "022aeaf68d46fd39b23aca9c577f3f41", "_journal/2024-12-26.md": "022aeaf68d46fd39b23aca9c577f3f41",
"_journal/2024-12/2024-12-25.md": "1717d37b074df58175ec0272adc278de", "_journal/2024-12/2024-12-25.md": "1717d37b074df58175ec0272adc278de",
@ -1465,15 +1465,18 @@
"_journal/2025-01-16.md": "e3a21059205784a4e88bfe3b4deac7f7", "_journal/2025-01-16.md": "e3a21059205784a4e88bfe3b4deac7f7",
"_journal/2025-01-17.md": "08a5f05bb572db9495bfc2b4feb8e0a9", "_journal/2025-01-17.md": "08a5f05bb572db9495bfc2b4feb8e0a9",
"_journal/2025-01/2025-01-16.md": "e3a21059205784a4e88bfe3b4deac7f7", "_journal/2025-01/2025-01-16.md": "e3a21059205784a4e88bfe3b4deac7f7",
"trigonometry/index.md": "b48577b0c5c6e4d587d597a0fcd08b0f", "trigonometry/index.md": "bba87fba2825095cd727c7561906e4dc",
"geometry/circle.md": "9469e5512a6a92a962985eab99d00606", "geometry/circle.md": "9469e5512a6a92a962985eab99d00606",
"_journal/2025-01-18.md": "8655fbf94aeec13efe9b6d2087c1f37e", "_journal/2025-01-18.md": "8655fbf94aeec13efe9b6d2087c1f37e",
"_journal/2025-01/2025-01-17.md": "08a5f05bb572db9495bfc2b4feb8e0a9", "_journal/2025-01/2025-01-17.md": "08a5f05bb572db9495bfc2b4feb8e0a9",
"_journal/2025-01-19.md": "a37c6f534cf5e272619c5f813974afcf", "_journal/2025-01-19.md": "a37c6f534cf5e272619c5f813974afcf",
"_journal/2025-01/2025-01-18.md": "7a1655887093f37ffe86309d90459b3b", "_journal/2025-01/2025-01-18.md": "7a1655887093f37ffe86309d90459b3b",
"_journal/2025-01-20.md": "2478f31199c1f0c2ffae2616b1ca435d", "_journal/2025-01-20.md": "705040c268bd54d363753b09bfac37cf",
"_journal/2025-01/2025-01-19.md": "65a56dcadec4f36c3a801cfb0de1a391", "_journal/2025-01/2025-01-19.md": "65a56dcadec4f36c3a801cfb0de1a391",
"trigonometry/unit-circle.md": "4a8fb4b5ac1bc2b645f18b0b8079897c" "trigonometry/unit-circle.md": "2d4fea38b543797f3d2237b645a07642",
"c17/types/compatible.md": "0aceb7385d878feacc7a70b9839d3450",
"_journal/2025-01-21.md": "d6475cfff346315718a8ef6ef1ff408f",
"_journal/2025-01/2025-01-20.md": "a206195abd13b7020e703bdcf11bdcdd"
}, },
"fields_dict": { "fields_dict": {
"Basic": [ "Basic": [

View File

@ -9,5 +9,5 @@ title: "2024-09-28"
- [ ] Korean (Read 1 Story) - [ ] Korean (Read 1 Story)
* Walked through the proof of the recursion theorem on $\omega$. * Walked through the proof of the recursion theorem on $\omega$.
* Additional notes on [[simple#Exact-Width Integer Types|exact-width integer types]]. * Additional notes on [[types/index#Exact-Width|exact-width integer types]].
* Severy more notes on C types/limits/etc. * Severy more notes on C types/limits/etc.

View File

@ -8,4 +8,4 @@ title: "2024-10-03"
- [ ] Sheet Music (10 min.) - [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story) - [ ] Korean (Read 1 Story)
* Begin adding notes on C [[derived|derived types]]. * Begin adding notes on C [[c17/types/index#Derived Types|derived types]].

View File

@ -9,4 +9,4 @@ title: "2024-11-23"
- [ ] Korean (Read 1 Story) - [ ] Korean (Read 1 Story)
* Notes on Apostol's axiomatic definition of [[area]]. * Notes on Apostol's axiomatic definition of [[area]].
* More notes on [[derived#Pointers|pointers]]. * More notes on [[pointers|pointers]].

View File

@ -8,4 +8,4 @@ title: "2024-11-24"
- [ ] Sheet Music (10 min.) - [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story) - [ ] Korean (Read 1 Story)
* Notes on the [[derived#NULL|NULL]] macro. * Notes on the [[pointers#NULL|NULL]] macro.

View File

@ -1,9 +0,0 @@
---
title: "2025-01-20"
---
- [ ] Anki Flashcards
- [x] KoL
- [x] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)

View File

@ -0,0 +1,9 @@
---
title: "2025-01-21"
---
- [x] Anki Flashcards
- [x] KoL
- [x] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)

View File

@ -0,0 +1,13 @@
---
title: "2025-01-20"
---
- [x] Anki Flashcards
- [x] KoL
- [x] OGS
- [ ] Sheet Music (10 min.)
- [ ] Korean (Read 1 Story)
* More flashcards on $\sin$, $\cos$, and the [[trigonometry/index#Pythagorean Identity|Pythagorean Identity]].
* Watched [Space Filling Curves](https://www.youtube.com/watch?v=3s7h2MHQtxc), which provided a concrete example of $\mathbb{R} \times \mathbb{R} \approx \mathbb{R}$.
* Begin adding notes on [[compatible|compatible types]].

View File

@ -230,7 +230,7 @@ A **definition** is a declaration that causes storage to be reserved for the obj
%%ANKI %%ANKI
Basic Basic
A definition contains how many declarators? A definition contains how many declarators?
Back: One. Back: One or more.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf). Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1733401142082--> <!--ID: 1733401142082-->
END%% END%%
@ -349,6 +349,555 @@ Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co
<!--ID: 1725196290208--> <!--ID: 1725196290208-->
END%% END%%
## Prototypes
There exist two ways for a function declaration to use declarators: **parameter type lists** and **identifier type lists**. To make the distinction clear, consider the following ways of defining an `add` function:
```c
int f(int x, int y) { return x + y; } // Paramter type list
int f(x, y) int x; int y; { return x + y } // Identifier type list
```
A function **prototype** is a function declaration that specifies a function signature. There are three important points to make note of:
* Empty identifier lists are interpreted as "the compiler has not been told what this function's arguments are."
* The standard prohibits declaring functions with a non-empty identifier list.
* Empty parameter lists are not allowed.
Therefore:
```c
// Uses an empty identifer list. This declares a function `foo`
// that takes an unknown specification of arguments.
void foo();
// Uses a non-empty identifier list. Compiler error.
void foo(x, y);
// Uses a non-empty identifier list. Compiler error.
void foo(x, y) int x; int y;
// Uses a non-empty identifier list. Definitions allow this.
void foo(x, y) int x; int y; { }
// Uses a non-empty parameter list. This prototypes a function
// `foo` that takes no arguments.
void foo(void);
// Uses a non-empty parameter list. This prototypes and defines
// a function `foo` that takes no arguments.
void foo(void) {}
```
Together these points imply a function prototype *must* use a parameter type list.
%%ANKI
Basic
Which of prototypes or declarations are more general?
Back: Declarations.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751462-->
END%%
%%ANKI
Basic
What two ways are parameters declared in function declarations and definitions?
Back: Identifier type lists and parameter type lists.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751467-->
END%%
%%ANKI
Basic
Which of identifier type lists and/or parameter type lists are considered obsolete?
Back: Identifier type lists.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751470-->
END%%
%%ANKI
Basic
Define an addition function using identifier type lists.
Back:
```c
int add(x, y) int x; int y; { return x + y; }
```
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751473-->
END%%
%%ANKI
Basic
Define an addition function using parameter type lists.
Back:
```c
int add(int x, int y) { return x + y; }
```
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751476-->
END%%
%%ANKI
Basic
Is the following a prototype or a declaration?
```c
void foo();
```
Back: A declaration.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751479-->
END%%
%%ANKI
Basic
What compilation error does the following raise?
```c
void foo();
```
Back: N/A.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751482-->
END%%
%%ANKI
Basic
What compilation error does the following raise?
```c
void foo(x, y);
```
Back: A function declaration cannot have a non-empty identifier list.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751486-->
END%%
%%ANKI
Basic
What compilation error does the following raise?
```c
void foo(x, y) int x; int y;
```
Back: A function declaration cannot have a non-empty identifier list.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751490-->
END%%
%%ANKI
Basic
What compilation error does the following raise?
```c
void foo(x, y) int x; int y; {}
```
Back: N/A.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751495-->
END%%
%%ANKI
Basic
What function prototype is declared in the following?
```c
void foo(x, y) int x; int y; {}
```
Back: N/A. No prototype has been declared.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751499-->
END%%
%%ANKI
Basic
What compilation error does the following raise?
```c
void foo();
int main(void) { foo(1); }
```
Back: N/A.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751504-->
END%%
%%ANKI
Basic
Is the following a prototype, declaration, both, or neither?
```c
void f();
```
Back: A declaration.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1733492504375-->
END%%
%%ANKI
Basic
Is the following a prototype, declaration, both, or neither?
```c
void f(void);
```
Back: Both.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751509-->
END%%
%%ANKI
Basic
What compilation error does the following raise?
```c
void foo(void);
```
Back: N/A.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751513-->
END%%
%%ANKI
Basic
What compilation error does the following raise?
```c
void foo(void);
int main(void) { foo(1); }
```
Back: Too many arguments to function call `foo`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751518-->
END%%
%%ANKI
Basic
What function prototype is declared in the following?
```c
void foo(int x, int y);
```
Back: `void foo(int, int)`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751522-->
END%%
%%ANKI
Basic
What function prototype is declared in the following?
```c
void foo(int x, int y) {}
```
Back: `void foo(int, int)`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751527-->
END%%
%%ANKI
Basic
How many arguments does the following declaration specify?
```c
void foo();
```
Back: Some number unknown to the compiler.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751531-->
END%%
%%ANKI
Basic
How many arguments does the following declaration specify?
```c
void foo(void);
```
Back: Zero.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751535-->
END%%
%%ANKI
Basic
Why might the following snippet raise a compilation error?
```c
int foo();
int foo(int a);
```
Back: N/A. It likely wouldn't.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751539-->
END%%
%%ANKI
Basic
*Why* might the following snippet raise a compilation error?
```c
int foo();
int foo(float a);
```
Back: Conflicting types. The first `foo` declares any `float` passed to it default promotes to a `double`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751543-->
END%%
%%ANKI
Basic
*Why* might the following snippet raise a compilation error?
```c
int foo();
int foo(char a);
```
Back: Conflicting types. The first `foo` declares any `char` passed to it default promotes to an `int`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751547-->
END%%
%%ANKI
Basic
*Why* might the following snippet raise a compilation error?
```c
int foo();
int foo(double a);
```
Back: N/A. It likely wouldn't.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751552-->
END%%
### main
`main` is a special function serving as the entrypoint to C programs. It can have several different prototypes, but the following two are always possible:
```c
int main(void);
int main(int argc, char* argv[argc+1]);
```
The only two return values guaranteed to work on all platform is `EXIT_SUCCESS` and `EXIT_FAILURE`. Reaching the end of `main` is equivalent to a `reutrn` with value `EXIT_SUCCESS`.
%%ANKI
Basic
Which function serves as the entrypoint of C programs?
Back: `main`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415792-->
END%%
%%ANKI
Basic
How many possible valid prototypes of `main` are available?
Back: Indeterminate. Depends on the system.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415798-->
END%%
%%ANKI
Basic
How many "official" prototypes of `main` are available?
Back: Two.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415801-->
END%%
%%ANKI
Basic
What are the "official" prototypes of `main`?
Back:
```c
int main(void);
int main(int argc, char* argv[argc + 1]);
```
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415804-->
END%%
%%ANKI
Basic
What are the "official" prototypes of `main`?
Back:
```c
int main(void);
int main(int argc, char* argv[argc + 1]);
```
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
END%%
%%ANKI
Basic
What are the only portable values that `main` can return?
Back: `EXIT_SUCCESS` and `EXIT_FAILURE`.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415807-->
END%%
%%ANKI
Basic
Which library defines `EXIT_SUCCESS`?
Back: `<stdlib.h>`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415810-->
END%%
%%ANKI
Basic
Which library defines `EXIT_FAILURE`?
Back: `<stdlib.h>`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415813-->
END%%
%%ANKI
Basic
What happens when `main` does not explicitly return a value?
Back: `EXIT_SUCCESS` is implicitly returned.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415816-->
END%%
%%ANKI
Cloze
Returning {1:`s`} in {1:`main`} is equivalent to invoking function {2:`exit`} with argument {2:`s`}.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415819-->
END%%
%%ANKI
Basic
Which library declares the following prototype?
```c
noreturn void exit(int)
```
Back: `<stdlib.h>`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415823-->
END%%
%%ANKI
Basic
What does keyword `_Noreturn` indicate?
Back: The associated callee will never return control back to the caller.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415827-->
END%%
%%ANKI
Basic
What kind of syntactical construct is `_Noreturn`?
Back: A special keyword.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415832-->
END%%
%%ANKI
Basic
What kind of syntactical construct is `noreturn`?
Back: A macro.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415836-->
END%%
%%ANKI
Cloze
{1:`_Noreturn`} is a {2:keyword} whereas {2:`noreturn`} is a {1:macro}.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415841-->
END%%
%%ANKI
Basic
Which library is `noreturn` defined in?
Back: `<stdnoreturn.h>`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415846-->
END%%
%%ANKI
Basic
Consider the following prototype. What is the value of `argv[0]`?
```c
int main(int argc, char* argv[argc + 1]);
```
Back: The name of the program invocation.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415851-->
END%%
%%ANKI
Basic
Consider the following prototype. What is the value of `argv[argc]`?
```c
int main(int argc, char* argv[argc + 1]);
```
Back: `0`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415856-->
END%%
%%ANKI
Basic
Consider the following prototype. What is the value of `argv[1]`?
```c
int main(int argc, char* argv[argc + 1]);
```
Back: `0` if `argc == 1` else the first argument to the program.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415860-->
END%%
%%ANKI
Basic
Consider the following prototype. What is the minimum value of `argc`?
```c
int main(int argc, char* argv[argc + 1]);
```
Back: `1`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415865-->
END%%
%%ANKI
Basic
Consider the following prototype. What is the minimum length of `argv`?
```c
int main(int argc, char* argv[argc + 1]);
```
Back: `2`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415869-->
END%%
### Variable-Length Arrays
Within a function prototype, a parameter can denote a [[c17/types/index#Variable-Length|VLA]] using `[*]` syntax. For example, the following prototypes are all (more or less) equivalent:
```c
int sum2d(int , int , int a[*][*]);
int sum2d(int n, int , int a[n][*]);
int sum2d(int , int m, int a[*][m]);
int sum2d(int n, int m, int a[n][m]);
int sum2d(int , int , int a[][*]);
int sum2d(int , int , int (*a)[*]);
int sum2d(int , int m, int (*a)[m]);
```
%%ANKI
Basic
In what context are VLAs declared with `[*]` actually useful?
Back: Function prototypes.
Reference: https://stackoverflow.com/a/17371914
<!--ID: 1733144155068-->
END%%
%%ANKI
Basic
Maintaining array syntax, rewrite the following without parameter names.
```c
int sum2d(int n, int m, int a[n][m]);
```
Back:
```c
int sum2d(int, int, int a[*][*]);
```
Reference: https://stackoverflow.com/a/17371914
<!--ID: 1733144155073-->
END%%
%%ANKI
Basic
*Why* is the first `*` considered redundant in the following?
```c
int sum2d(int, int, int a[*][*]);
```
Back: Array decay.
Reference: https://stackoverflow.com/a/17371914
<!--ID: 1733144155076-->
END%%
## Precedence Rules ## Precedence Rules
Declarations can be read by complying with the precedence rules outlined below: Declarations can be read by complying with the precedence rules outlined below:

View File

@ -1,666 +0,0 @@
---
title: Functions
TARGET DECK: Obsidian::STEM
FILE TAGS: c17::function
tags:
- c17
---
## Overview
A function `f` without a following opening `(` is converted to a pointer to its start. This is called **function decay**.
%%ANKI
Basic
What is the effect of function decay?
Back: Evaluation of a function `f` without a following opening `(` is converted to a pointer to its start.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953243-->
END%%
%%ANKI
Basic
What name is given to the implicit conversion of a function to a pointer?
Back: Function decay.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953247-->
END%%
%%ANKI
Basic
According to Gustedt, what C feature explains why are there no "function values"?
Back: Function-to-pointer decay.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953250-->
END%%
%%ANKI
Basic
Why can't functions directly be made arguments to functions?
Back: Because function arguments decay to pointers.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953255-->
END%%
%%ANKI
Cloze
{1:Function pointers} are to {2:`(...)`} whereas {2:pointers} are to {1:`[...]`}.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953260-->
END%%
%%ANKI
Basic
In what order are decays, dereferences, address ofs, and calls performed in the following?
```c
f(3);
```
Back: Decay, call.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953264-->
END%%
%%ANKI
Basic
In what order are decays, dereferences, address ofs, and calls performed in the following?
```c
(&f)(3);
```
Back: Address of, call.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953269-->
END%%
%%ANKI
Basic
In what order are decays, dereferences, address ofs, and calls performed in the following?
```c
(*f)(3);
```
Back: Decay, dereference, decay, call.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953273-->
END%%
%%ANKI
Basic
In what order are decays, dereferences, address ofs, and calls performed in the following?
```c
(*&f)(3);
```
Back: Address of, dereference, decay, call.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953277-->
END%%
%%ANKI
Basic
In what order are decays, dereferences, address ofs, and calls performed in the following?
```c
(&*f)(3);
```
Back: Decay, dereference, address of, call.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953281-->
END%%
%%ANKI
Cloze
{1:Pointers} refer to {2:arrays} whereas {2:function pointers} refer to {1:functions}.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953285-->
END%%
## Prototypes
There exist two ways for a function [[c17/declarations|declaration]] to use declarators: **parameter type lists** and **identifier type lists**. To make the distinction clear, consider the following ways of defining an `add` function:
```c
int f(int x, int y) { return x + y; } // Paramter type list
int f(x, y) int x; int y; { return x + y } // Identifier type list
```
A function **prototype** is a function declaration that specifies a function signature. There are three important points to make note of:
* Empty identifier lists are interpreted as "the compiler has not been told what this function's arguments are."
* The standard prohibits declaring functions with a non-empty identifier list.
* Empty parameter lists are not allowed.
Therefore:
```c
// Uses an empty identifer list. This declares a function `foo`
// that takes an unknown specification of arguments.
void foo();
// Uses a non-empty identifier list. Compiler error.
void foo(x, y);
// Uses a non-empty identifier list. Compiler error.
void foo(x, y) int x; int y;
// Uses a non-empty identifier list. Definitions allow this.
void foo(x, y) int x; int y; { }
// Uses a non-empty parameter list. This prototypes a function
// `foo` that takes no arguments.
void foo(void);
// Uses a non-empty parameter list. This prototypes and defines
// a function `foo` that takes no arguments.
void foo(void) {}
```
Together these points imply a function prototype *must* use a parameter type list.
%%ANKI
Basic
Which of prototypes or declarations are more general?
Back: Declarations.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751462-->
END%%
%%ANKI
Basic
What two ways are parameters declared in function declarations and definitions?
Back: Identifier type lists and parameter type lists.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751467-->
END%%
%%ANKI
Basic
Which of identifier type lists and/or parameter type lists are considered obsolete?
Back: Identifier type lists.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751470-->
END%%
%%ANKI
Basic
Define an addition function using identifier type lists.
Back:
```c
int add(x, y) int x; int y; { return x + y; }
```
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751473-->
END%%
%%ANKI
Basic
Define an addition function using parameter type lists.
Back:
```c
int add(int x, int y) { return x + y; }
```
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751476-->
END%%
%%ANKI
Basic
Is the following a prototype or a declaration?
```c
void foo();
```
Back: A declaration.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751479-->
END%%
%%ANKI
Basic
What compilation error does the following raise?
```c
void foo();
```
Back: N/A.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751482-->
END%%
%%ANKI
Basic
What compilation error does the following raise?
```c
void foo(x, y);
```
Back: A function declaration cannot have a non-empty identifier list.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751486-->
END%%
%%ANKI
Basic
What compilation error does the following raise?
```c
void foo(x, y) int x; int y;
```
Back: A function declaration cannot have a non-empty identifier list.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751490-->
END%%
%%ANKI
Basic
What compilation error does the following raise?
```c
void foo(x, y) int x; int y; {}
```
Back: N/A.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751495-->
END%%
%%ANKI
Basic
What function prototype is declared in the following?
```c
void foo(x, y) int x; int y; {}
```
Back: N/A. No prototype has been declared.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751499-->
END%%
%%ANKI
Basic
What compilation error does the following raise?
```c
void foo();
int main(void) { foo(1); }
```
Back: N/A.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751504-->
END%%
%%ANKI
Basic
Is the following a prototype, declaration, both, or neither?
```c
void f();
```
Back: A declaration.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1733492504375-->
END%%
%%ANKI
Basic
Is the following a prototype, declaration, both, or neither?
```c
void f(void);
```
Back: Both.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751509-->
END%%
%%ANKI
Basic
What compilation error does the following raise?
```c
void foo(void);
```
Back: N/A.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751513-->
END%%
%%ANKI
Basic
What compilation error does the following raise?
```c
void foo(void);
int main(void) { foo(1); }
```
Back: Too many arguments to function call `foo`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751518-->
END%%
%%ANKI
Basic
What function prototype is declared in the following?
```c
void foo(int x, int y);
```
Back: `void foo(int, int)`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751522-->
END%%
%%ANKI
Basic
What function prototype is declared in the following?
```c
void foo(int x, int y) {}
```
Back: `void foo(int, int)`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751527-->
END%%
%%ANKI
Basic
How many arguments does the following declaration specify?
```c
void foo();
```
Back: Some number unknown to the compiler.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751531-->
END%%
%%ANKI
Basic
How many arguments does the following declaration specify?
```c
void foo(void);
```
Back: Zero.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751535-->
END%%
%%ANKI
Basic
Why might the following snippet raise a compilation error?
```c
int foo();
int foo(int a);
```
Back: N/A. It likely wouldn't.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751539-->
END%%
%%ANKI
Basic
*Why* might the following snippet raise a compilation error?
```c
int foo();
int foo(float a);
```
Back: Conflicting types. The first `foo` declares any `float` passed to it default promotes to a `double`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751543-->
END%%
%%ANKI
Basic
*Why* might the following snippet raise a compilation error?
```c
int foo();
int foo(char a);
```
Back: Conflicting types. The first `foo` declares any `char` passed to it default promotes to an `int`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751547-->
END%%
%%ANKI
Basic
*Why* might the following snippet raise a compilation error?
```c
int foo();
int foo(double a);
```
Back: N/A. It likely wouldn't.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1732031751552-->
END%%
### main
`main` is a special function serving as the entrypoint to C programs. It can have several different prototypes, but the following two are always possible:
```c
int main(void);
int main(int argc, char* argv[argc+1]);
```
The only two return values guaranteed to work on all platform is `EXIT_SUCCESS` and `EXIT_FAILURE`. Reaching the end of `main` is equivalent to a `reutrn` with value `EXIT_SUCCESS`.
%%ANKI
Basic
Which function serves as the entrypoint of C programs?
Back: `main`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415792-->
END%%
%%ANKI
Basic
How many possible valid prototypes of `main` are available?
Back: Indeterminate. Depends on the system.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415798-->
END%%
%%ANKI
Basic
How many "official" prototypes of `main` are available?
Back: Two.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415801-->
END%%
%%ANKI
Basic
What are the "official" prototypes of `main`?
Back:
```c
int main(void);
int main(int argc, char* argv[argc + 1]);
```
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415804-->
END%%
%%ANKI
Basic
What are the "official" prototypes of `main`?
Back:
```c
int main(void);
int main(int argc, char* argv[argc + 1]);
```
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
END%%
%%ANKI
Basic
What are the only portable values that `main` can return?
Back: `EXIT_SUCCESS` and `EXIT_FAILURE`.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415807-->
END%%
%%ANKI
Basic
Which library defines `EXIT_SUCCESS`?
Back: `<stdlib.h>`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415810-->
END%%
%%ANKI
Basic
Which library defines `EXIT_FAILURE`?
Back: `<stdlib.h>`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415813-->
END%%
%%ANKI
Basic
What happens when `main` does not explicitly return a value?
Back: `EXIT_SUCCESS` is implicitly returned.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415816-->
END%%
%%ANKI
Cloze
Returning {1:`s`} in {1:`main`} is equivalent to invoking function {2:`exit`} with argument {2:`s`}.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415819-->
END%%
%%ANKI
Basic
Which library declares the following prototype?
```c
noreturn void exit(int)
```
Back: `<stdlib.h>`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415823-->
END%%
%%ANKI
Basic
What does keyword `_Noreturn` indicate?
Back: The associated callee will never return control back to the caller.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415827-->
END%%
%%ANKI
Basic
What kind of syntactical construct is `_Noreturn`?
Back: A special keyword.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415832-->
END%%
%%ANKI
Basic
What kind of syntactical construct is `noreturn`?
Back: A macro.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415836-->
END%%
%%ANKI
Cloze
{1:`_Noreturn`} is a {2:keyword} whereas {2:`noreturn`} is a {1:macro}.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415841-->
END%%
%%ANKI
Basic
Which library is `noreturn` defined in?
Back: `<stdnoreturn.h>`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415846-->
END%%
%%ANKI
Basic
Consider the following prototype. What is the value of `argv[0]`?
```c
int main(int argc, char* argv[argc + 1]);
```
Back: The name of the program invocation.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415851-->
END%%
%%ANKI
Basic
Consider the following prototype. What is the value of `argv[argc]`?
```c
int main(int argc, char* argv[argc + 1]);
```
Back: `0`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415856-->
END%%
%%ANKI
Basic
Consider the following prototype. What is the value of `argv[1]`?
```c
int main(int argc, char* argv[argc + 1]);
```
Back: `0` if `argc == 1` else the first argument to the program.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415860-->
END%%
%%ANKI
Basic
Consider the following prototype. What is the minimum value of `argc`?
```c
int main(int argc, char* argv[argc + 1]);
```
Back: `1`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415865-->
END%%
%%ANKI
Basic
Consider the following prototype. What is the minimum length of `argv`?
```c
int main(int argc, char* argv[argc + 1]);
```
Back: `2`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732293415869-->
END%%
### Variable-Length Arrays
Within a function prototype, a parameter can denote a [[derived#Variable-Length|VLA]] using `[*]` syntax. For example, the following prototypes are all (more or less) equivalent:
```c
int sum2d(int , int , int a[*][*]);
int sum2d(int n, int , int a[n][*]);
int sum2d(int , int m, int a[*][m]);
int sum2d(int n, int m, int a[n][m]);
int sum2d(int , int , int a[][*]);
int sum2d(int , int , int (*a)[*]);
int sum2d(int , int m, int (*a)[m]);
```
%%ANKI
Basic
In what context are VLAs declared with `[*]` actually useful?
Back: Function prototypes.
Reference: https://stackoverflow.com/a/17371914
<!--ID: 1733144155068-->
END%%
%%ANKI
Basic
Maintaining array syntax, rewrite the following without parameter names.
```c
int sum2d(int n, int m, int a[n][m]);
```
Back:
```c
int sum2d(int, int, int a[*][*]);
```
Reference: https://stackoverflow.com/a/17371914
<!--ID: 1733144155073-->
END%%
%%ANKI
Basic
*Why* is the first `*` considered redundant in the following?
```c
int sum2d(int, int, int a[*][*]);
```
Back: Array decay.
Reference: https://stackoverflow.com/a/17371914
<!--ID: 1733144155076-->
END%%
## Bibliography
* “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
* Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).

View File

@ -562,7 +562,7 @@ END%%
## Aliasing ## Aliasing
Accessing the same object through different pointers is called **aliasing**. With the exclusion of [[simple#Character Types|character types]], only pointers of the same base type may alias. Accessing the same object through different pointers is called **aliasing**. With the exclusion of [[types/index#Character Types|character types]], only pointers of the same base type may alias.
%%ANKI %%ANKI
Basic Basic

View File

@ -357,7 +357,7 @@ Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co
<!--ID: 1733242332384--> <!--ID: 1733242332384-->
END%% END%%
For these objects that do not have a [[derived#Variable-Length|VLA]] type, its lifetime extends from entry into its enclosing block until execution of that block ends. Its initial value is indeterminate. If initialization is specified, it is performed each time the declaration or compound literal is reached in the execution of the block. For these objects that do not have a [[c17/types/index#Variable-Length|VLA]] type, its lifetime extends from entry into its enclosing block until execution of that block ends. Its initial value is indeterminate. If initialization is specified, it is performed each time the declaration or compound literal is reached in the execution of the block.
For these objects that do have a VLA type, its lifetime extends from the declaration of the object until execution of the program leaves the scope of the declaration. For these objects that do have a VLA type, its lifetime extends from the declaration of the object until execution of the program leaves the scope of the declaration.
@ -675,7 +675,7 @@ END%%
In contrast to `auto`, there also exists a `register` [[#Storage-Class Specifiers|storage-class specifier]]. The `&` operator is not allowed for variables declared with `register` meaning variables declared with `register` can't [[pointers#Aliasing|alias]]. In contrast to `auto`, there also exists a `register` [[#Storage-Class Specifiers|storage-class specifier]]. The `&` operator is not allowed for variables declared with `register` meaning variables declared with `register` can't [[pointers#Aliasing|alias]].
Because of [[derived#Arrays|array-to-pointer decay]], arrays with storage-class `register` are useless. Because of [[types/index#Arrays|array-to-pointer decay]], arrays with storage-class `register` are useless.
%%ANKI %%ANKI
Basic Basic
@ -984,7 +984,6 @@ END%%
Storage-class specifiers are used to control an object's storage duration and an identifier's linkage. There are six storage-class specifiers: Storage-class specifiers are used to control an object's storage duration and an identifier's linkage. There are six storage-class specifiers:
* `typedef` * `typedef`
* Discussed in [[typedefs]].
* Is called a "storage-class specifier" for syntactic convenience only. * Is called a "storage-class specifier" for syntactic convenience only.
* `extern` * `extern`
* Discussed in [[linkage]] and [[#Static]]. * Discussed in [[linkage]] and [[#Static]].
@ -1007,22 +1006,6 @@ Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open
<!--ID: 1733242332426--> <!--ID: 1733242332426-->
END%% END%%
%%ANKI
Basic
Which storage-class specifier isn't *really* a storage-class specifier?
Back: `typedef`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1733242332430-->
END%%
%%ANKI
Basic
Syntactically, what makes `typedef` a special storage-class specifier?
Back: It is labeled a "storage-class specifier" for syntactic convenience.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1733242332435-->
END%%
%%ANKI %%ANKI
Basic Basic
A `_Thread_local` storage-class specifier can appear next to what other specifier(s)? A `_Thread_local` storage-class specifier can appear next to what other specifier(s)?
@ -1079,7 +1062,171 @@ Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open
<!--ID: 1733242459501--> <!--ID: 1733242459501-->
END%% END%%
### typedefs
The `<stddef.h>` header defines a few standard `typedef`s:
* `ptrdiff_t`: the signed integer type of the result of subtracting two pointers.
* `size_t`: the unsigned integer type of the result of the `sizeof` operator.
The standard often uses `typedef`s ending with `_t`.
%%ANKI
Basic
Which storage-class specifier isn't *really* a storage-class specifier?
Back: `typedef`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1733242332430-->
END%%
%%ANKI
Basic
Syntactically, what makes `typedef` a special storage-class specifier?
Back: It is labeled a "storage-class specifier" for syntactic convenience.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1733242332435-->
END%%
%%ANKI
Basic
What is the type of `x` in the following?
```c
#define int_ptr int *
int_ptr x, y;
```
Back: `int *`
Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
<!--ID: 1722786892109-->
END%%
%%ANKI
Basic
What is the type of `y` in the following?
```c
#define int_ptr int *
int_ptr x, y;
```
Back: `int`
Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
<!--ID: 1722786892110-->
END%%
%%ANKI
Basic
What is the type of `x` in the following?
```c
typedef int_ptr int *
int_ptr x, y;
```
Back: `int *`
Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
<!--ID: 1722786892111-->
END%%
%%ANKI
Basic
What is the type of `y` in the following?
```c
typedef int_ptr int *
int_ptr x, y;
```
Back: `int *`
Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
<!--ID: 1722786892112-->
END%%
%%ANKI
Basic
What header defines `size_t`?
Back: `<stddef.h>`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1730740461658-->
END%%
%%ANKI
Basic
What header defines `ptrdiff_t`?
Back: `<stddef.h>`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1730740461659-->
END%%
%%ANKI
Basic
`ptrdiff_t` is used as the type of what result?
Back: Subtracting two pointers.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1730740461660-->
END%%
%%ANKI
Basic
`size_t` is used as the type of what result?
Back: The `sizeof` operation.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1730740461661-->
END%%
%%ANKI
Basic
Is `ptrdiff_t` signed or unsigned?
Back: Signed.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1730740461662-->
END%%
%%ANKI
Basic
When can two pointers be subtracted?
Back: Only if both refer to elements of the same array object.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732397726963-->
END%%
%%ANKI
Basic
What is the result of `p - q` in the following?
```c
double A[4] = { 0.0, 1.0, 2.0, -3.0 };
double* p = &A[1];
double* q = &A[3];
```
Back: `-2`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732397726964-->
END%%
%%ANKI
Basic
What is the result of `p - q` in the following?
```c
double A[4] = { 0.0, 1.0, 2.0, -3.0 };
double* p = &A[3];
double* q = &A[1];
```
Back: `2`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732397726965-->
END%%
%%ANKI
Basic
Is `size_t` signed or unsigned?
Back: Unsigned.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1730740461663-->
END%%
%%ANKI
Basic
The C standard typically suffixes `typedef`s with what?
Back: `_t`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730758755507-->
END%%
## Bibliography ## Bibliography
* “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf). * “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
* Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020). * Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
* Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.

View File

@ -1,160 +0,0 @@
---
title: Typedefs
TARGET DECK: Obsidian::STEM
FILE TAGS: c17::type
tags:
- c17
---
## Overview
The `<stddef.h>` header defines a few standard `typedef`s:
* `ptrdiff_t`: the signed integer type of the result of subtracting two pointers.
* `size_t`: the unsigned integer type of the result of the `sizeof` operator.
The standard often uses `typedef`s ending with `_t`.
%%ANKI
Basic
What is the type of `x` in the following?
```c
#define int_ptr int *
int_ptr x, y;
```
Back: `int *`
Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
<!--ID: 1722786892109-->
END%%
%%ANKI
Basic
What is the type of `y` in the following?
```c
#define int_ptr int *
int_ptr x, y;
```
Back: `int`
Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
<!--ID: 1722786892110-->
END%%
%%ANKI
Basic
What is the type of `x` in the following?
```c
typedef int_ptr int *
int_ptr x, y;
```
Back: `int *`
Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
<!--ID: 1722786892111-->
END%%
%%ANKI
Basic
What is the type of `y` in the following?
```c
typedef int_ptr int *
int_ptr x, y;
```
Back: `int *`
Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
<!--ID: 1722786892112-->
END%%
%%ANKI
Basic
What header defines `size_t`?
Back: `<stddef.h>`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1730740461658-->
END%%
%%ANKI
Basic
What header defines `ptrdiff_t`?
Back: `<stddef.h>`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1730740461659-->
END%%
%%ANKI
Basic
`ptrdiff_t` is used as the type of what result?
Back: Subtracting two pointers.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1730740461660-->
END%%
%%ANKI
Basic
`size_t` is used as the type of what result?
Back: The `sizeof` operation.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1730740461661-->
END%%
%%ANKI
Basic
Is `ptrdiff_t` signed or unsigned?
Back: Signed.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1730740461662-->
END%%
%%ANKI
Basic
When can two pointers be subtracted?
Back: Only if both refer to elements of the same array object.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732397726963-->
END%%
%%ANKI
Basic
What is the result of `p - q` in the following?
```c
double A[4] = { 0.0, 1.0, 2.0, -3.0 };
double* p = &A[1];
double* q = &A[3];
```
Back: `-2`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732397726964-->
END%%
%%ANKI
Basic
What is the result of `p - q` in the following?
```c
double A[4] = { 0.0, 1.0, 2.0, -3.0 };
double* p = &A[3];
double* q = &A[1];
```
Back: `2`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732397726965-->
END%%
%%ANKI
Basic
Is `size_t` signed or unsigned?
Back: Unsigned.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1730740461663-->
END%%
%%ANKI
Basic
The C standard typically suffixes `typedef`s with what?
Back: `_t`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730758755507-->
END%%
## Bibliography
* “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
* Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
* Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.

View File

@ -0,0 +1,205 @@
---
title: Compatible Types
TARGET DECK: Obsidian::STEM
FILE TAGS: c17::type
tags:
- c17
---
## Overview
Two declarations with different types may still refer to the same object or function if they have **compatible types**.
A **composite type** is constructed from two compatible types. It is the type that is compatible with both of the original types, including every available array size and every available parameter list from the original types.
%%ANKI
Basic
What are compatible types?
Back: Types that can be used to refer to the same object or function.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1737431391551-->
END%%
%%ANKI
Cloze
A {composite} type is constructed from two {compatible} types.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1737431391558-->
END%%
## Simple Types
Disregarding enumerations, two different simple types are never compatible. For two simple types to be compatible, they must use the same qualifiers and their unqualified base types must be the same.
%%ANKI
Basic
Explain why `int` and `signed int` are compatible types or not.
Back: Compatible. `int` is an alias for `signed int`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1737431391561-->
END%%
%%ANKI
Basic
Explain why `int` and `unsigned int` are compatible types or not.
Back: Incompatible. They have different signedness.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1737431391564-->
END%%
%%ANKI
Basic
Explain why `unsigned int` and `signed int` are compatible types or not.
Back: Incompatible. They have different signedness.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1737431391568-->
END%%
%%ANKI
Basic
Explain why `const int` and `int` are compatible types or not.
Back: Incompatible. Type qualifiers must match.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1737431391571-->
END%%
%%ANKI
Basic
Explain why `const int` and `const` are compatible types or not.
Back: Compatbile. `const` without a type specifier assumes a `const int` type.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1737431391574-->
END%%
%%ANKI
Basic
Explain why `const int` and `volatile int` are compatible types or not.
Back: Incompatible. Type qualifiers must match.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1737431391577-->
END%%
%%ANKI
Basic
Explain why `float` and `double` are compatible types or not.
Back: Incompatible. Two different simple types are never compatible.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1737431391581-->
END%%
### Enumerations
An enumeration type must be compatible with a `char`, signed integer type, or unsigned integer type. The choice of type is implementation-defined, but shall be capable of representing the values of all the members of the enumeration.
%%ANKI
Basic
An enumerated type must be compatible with what three possibilities?
Back: A `char`, a signed integer type, or an unsigned integer type.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1733403803028-->
END%%
%%ANKI
Basic
What is the type given to an enumerated type?
Back: N/A. This is implementation-defined.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1733403803055-->
END%%
%%ANKI
Basic
What size restriction is enforced on the implementation-defined enumerated type?
Back: It must be capable of representing the values of all the members of the `enum`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1733403803058-->
END%%
%%ANKI
Basic
What kind of integer expressions are enumeration constants limited to?
Back: Integer constant expressions with value representable as an `int`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1727022810827-->
END%%
%%ANKI
Basic
Besides being an ICE, what other condition is expected on enumeration constants?
Back: The ICE evaluates to an integer that fits within an `int`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1727022810833-->
END%%
If two enumeration types are declared in separate translation units, they are compatible if they are declared with the same tag (or lack thereof) and there exists a one-to-one correspondence between their members such that each pair of corresponding members are declared with compatible types. Additionally, corresponding members must have the same values.
%%ANKI
Basic
Explain why the following `enums`, defined in different TUs, have compatible types or not.
```c
enum x { a = 1 };
enum x { a = 1 };
```
Back: Compatible. They are exactly the same.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1737431391584-->
END%%
%%ANKI
Basic
Explain why the following `enums`, defined in different TUs, have compatible types or not.
```c
enum x { a = 1 };
enum x { a = 2 };
```
Back: Incompatible. Corresponding members must have the same values.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1737431391588-->
END%%
%%ANKI
Basic
Explain why the following `enums`, defined in different TUs, have compatible types or not.
```c
enum x { a, b };
enum x { b, a };
```
Back: Incompatible. Corresponding members must have the same values.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1737431391591-->
END%%
%%ANKI
Basic
Explain why the following `enums`, defined in different TUs, have compatible types or not.
```c
enum x { a = 0, b };
enum x { b = 1, a = 0 };
```
Back: Compatible. Corresponding members have the same values.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1737431391595-->
END%%
%%ANKI
Basic
Explain why the following `enums`, defined in different TUs, have compatible types or not.
```c
enum x { a, b };
enum y { a, b };
```
Back: Incompatible. Tags `x` and `y` do not match.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1737431391598-->
END%%
## Derived Types
## Bibliography
* “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).

View File

@ -0,0 +1,314 @@
---
title: Conversions
TARGET DECK: Obsidian::STEM
FILE TAGS: c17::type
tags:
- c17
---
## Overview
> Several operators convert operand values from one type to another automatically.
The above quote refers to **implicit conversions**. Alternatively, we can use cast operations to perform **explicit conversions**.
## Usual Arithmetic Conversions
As a general rule, the result of an operation has the type of the operand with wider range. The usual arithmetic conversions behave according to the following pattern:
1. Determine a **common real type** for the operands and result.
2. Convert each operand, without change of type domain, to a type with real type matching the common real type.
3. Unless explicitly stated otherwise, the common real type is the corresponding real type of the result, whose type domain is that of the operands if they are the same and complex otherwise.
Common real types are prioritized in the following order:
1. `long double`
2. `double`
3. `float`
4. If both operands have the same signedness, the higher ranked type.
5. If the unsigned operand has rank $\geq$ than that of the other, the unsigned type.
6. If the signed operand's includes that of the other, the signed type.
7. The unsigned integer type corresponding to that of the signed integer type.
%%ANKI
Basic
What is the common real type of `a` and `b`?
```c
long double a;
long double complex b;
```
Back: `long double`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203391-->
END%%
%%ANKI
Basic
What is the common real type of `a` and `b`?
```c
long double a;
long complex b;
```
Back: `long double`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203395-->
END%%
%%ANKI
Basic
What is the type domain of `a + b`?
```c
long double a;
long complex b;
```
Back: Complex.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203398-->
END%%
%%ANKI
Basic
What is the common real type of `a` and `b`?
```c
double complex a;
long b;
```
Back: `double`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203402-->
END%%
%%ANKI
Basic
What is the type domain of `a + b`?
```c
long double a;
long complex b;
```
Back: Complex.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
END%%
%%ANKI
Basic
What is the common real type of `a` and `b`?
```c
float a;
double b;
```
Back: `double`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203405-->
END%%
%%ANKI
Basic
What is the common real type of `a` and `b`?
```c
long long a;
float b;
```
Back: `float`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203408-->
END%%
%%ANKI
Basic
What is the type domain of `a + b`?
```c
long long a;
float b;
```
Back: Real.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203419-->
END%%
%%ANKI
Basic
*Why* is the common real type of `a` and `b` equal to `float`?
```c
long long a;
float b;
```
Back: Because floating-point types have priority over integer types.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203427-->
END%%
%%ANKI
Basic
What is the type domain of `a + b`?
```c
long long a;
long long b;
```
Back: Real.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203431-->
END%%
%%ANKI
Basic
What is the common real type of `a` and `b`?
```c
long long a;
long long b;
```
Back: `long long`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203436-->
END%%
%%ANKI
Basic
What is the common real type of `a` and `b`?
```c
unsigned int a;
signed short b;
```
Back: `unsigned int`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203440-->
END%%
%%ANKI
Basic
What is the common real type of `a` and `b`?
```c
unsigned a;
signed int b;
```
Back: `unsigned`
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203445-->
END%%
%%ANKI
Basic
*Why* is the common real type of `a` and `b` equal to `unsigned`?
```c
unsigned a;
signed int b;
```
Back: Because `unsigned` has rank $\geq$ that of `signed int`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203450-->
END%%
%%ANKI
Basic
What is the type domain of `a + b`?
```c
unsigned a;
signed int b;
```
Back: Real.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203454-->
END%%
%%ANKI
Basic
What is the type domain of `a + b`?
```c
unsigned short a;
signed int b;
```
Back: Real.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203469-->
END%%
%%ANKI
Basic
What is the common real type of `a + b`?
```c
unsigned short a;
signed int b;
```
Back: Indeterminate.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1726840632804-->
END%%
%%ANKI
Basic
*Why* is the common real type of `a + b` indeterminate?
```c
unsigned short a;
int b;
```
Back: Because the rank of `unsigned short` is $<$ that of `int`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203475-->
END%%
%%ANKI
Basic
What *might* the common real type of `a + b` be?
```c
unsigned short a;
signed int b;
```
Back: `signed int` or `unsigned int`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203479-->
END%%
%%ANKI
Basic
When is the common real type of `a + b` equal to `signed int`?
```c
unsigned short a;
signed int b;
```
Back: When `signed int` can represent all the values of `unsigned short`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203484-->
END%%
%%ANKI
Basic
When is the common real type of `a + b` equal to `unsigned int`?
```c
unsigned short a;
signed int b;
```
Back: When `signed int` cannot represent all the values of `unsigned short`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203488-->
END%%
%%ANKI
Basic
When is the common real type of `a + b` equal to `unsigned short`?
```c
unsigned short a;
signed int b;
```
Back: N/A. It never is.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203492-->
END%%
%%ANKI
Basic
Suppose `a` and `b` has signed and unsigned types respectively. When is `a + b` signed?
Back: When `b`'s type has lower rank and the range of `b` is included in the range of `a`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203460-->
END%%
%%ANKI
Basic
Suppose `a` and `b` have signed and unsigned types respectively. When is `a + b` unsigned?
Back: When `b`'s type has higher rank or the range of `a` cannot fit the range of `b`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1724762203465-->
END%%
## Bibliography
* “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).

View File

@ -1,879 +0,0 @@
---
title: Derived Types
TARGET DECK: Obsidian::STEM
FILE TAGS: c17::type
tags:
- c17
---
## Overview
A type is said to be **derived** if they are defined relative to other types.
%%ANKI
Basic
What is a derived type?
Back: A type defined relative to other types.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575885-->
END%%
## Aggregate Data Types
The **aggregate data types** are so called because they combine multiple instances of one or several other data types.
%%ANKI
Basic
What are the two aggregate data types?
Back: Arrays and structures.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575896-->
END%%
%%ANKI
Basic
Why are the aggregate data types named the way they are?
Back: They combine multiple instances of one or several other data types.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575904-->
END%%
### Arrays
An array is a contiguous sequence of objects. An array is either a **fixed-length array** or a **variable-length array**.
%%ANKI
Cloze
{Arrays} combine items that all have the same {base type}.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575931-->
END%%
%%ANKI
Basic
What is the base type of the following array?
```c
double a[4];
```
Back: `double`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575934-->
END%%
%%ANKI
Basic
What is the base type of the following array?
```c
double a[4][4];
```
Back: `double[4]`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575942-->
END%%
%%ANKI
Basic
How are parentheses introduced to the following declaration without affecting meaning?
```c
double a[4][4];
```
Back:
```c
double (a[4])[4];
```
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575950-->
END%%
%%ANKI
Basic
Consider the following. How many objects make up `a[0]`?
```c
double a[M][N];
```
Back: `N`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575955-->
END%%
%%ANKI
Basic
Consider the following. How many objects make up `a[M - 1]`?
```c
double a[M][N];
```
Back: `N`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575960-->
END%%
%%ANKI
Basic
Consider the following. How many objects make up `a[N - 1]`?
```c
double a[M][N];
```
Back: Indeterminate. This may not be a valid array access.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575965-->
END%%
%%ANKI
Basic
Consider the following where `N < M`. How many objects make up `a[N - 1]`?
```c
double a[M][N];
```
Back: `N`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575971-->
END%%
%%ANKI
Basic
Consider the following where `M < N`. How many objects make up `a[N - 1]`?
```c
double a[M][N];
```
Back: N/A. Invalid array access.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575977-->
END%%
%%ANKI
Cloze
Array `a[M][N]` is a sequence of {1:`M`} objects each containing {1:`N`} objects.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575984-->
END%%
%%ANKI
Basic
Arrays fall under what two categories?
Back: Fixed-length and variable-length.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575990-->
END%%
%%ANKI
Basic
Replace `EXPR` in the following with an expression to compute the length of `A`.
```c
int A[N];
size_t len = EXPR;
```
Back: `(sizeof A) / (sizeof A[0])`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576053-->
END%%
%%ANKI
Basic
What two syntactic forms does the `sizeof` operator come in?
Back: With and without parentheses.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576058-->
END%%
%%ANKI
Basic
When can the `sizeof` operator elide parentheses?
Back: When operating on an object.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576068-->
END%%
%%ANKI
Basic
When does the `sizeof` operator *require* parentheses?
Back: When operating on a type.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576074-->
END%%
%%ANKI
Basic
Apply the possible syntactic forms of the `sizeof` operator to object `a`.
Back:
```c
sizeof a
sizeof(a)
```
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576079-->
END%%
%%ANKI
Basic
Apply the possible syntactic forms of the `sizeof` operator to type `int`.
Back:
```c
sizeof(int)
```
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576083-->
END%%
%%ANKI
Basic
Suppose I pass the following array to a function. Which dimension is lost?
```c
double a[M][N][P];
```
Back: `M`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1728244147560-->
END%%
%%ANKI
Basic
Why shouldn't you use the `sizeof` operator on array parameters to functions?
Back: The innermost dimension of an array parameter to a function is lost.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1728244147581-->
END%%
%%ANKI
Basic
How is the following array parameter rewritten using pointer syntax?
```c
void foo(int a[const]) {}
```
Back:
```c
void foo(int *const a) {}
```
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1728244147585-->
END%%
%%ANKI
Basic
How is the following array parameter rewritten using pointer syntax?
```c
void foo(const int a[]) {}
```
Back:
```c
void foo(const int *a) {}
```
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1728244147614-->
END%%
%%ANKI
Basic
How is the following pointer parameter rewritten using array syntax?
```c
void foo(int *restrict a) {}
```
Back:
```c
void foo(int a[restrict]) {}
```
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1728244147617-->
END%%
%%ANKI
Basic
How is the following pointer parameter rewritten using array syntax?
```c
void foo(volatile int *a) {}
```
Back:
```c
void foo(volatile int a[]) {}
```
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1728244147620-->
END%%
%%ANKI
Basic
What does the `3` keyword guarantee to the compiler?
```c
void bar(int a[3]);
```
Back: N/A. It is ignored.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1728244147623-->
END%%
%%ANKI
Basic
*Why* might you see e.g. `3` like in the following prototype?
```c
void bar(int a[3]);
```
Back: It serves as documentation.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1728244147625-->
END%%
%%ANKI
Basic
In the following, what does the `static` keyword guarantee to the compiler?
```c
void bar(int a[static 3]);
```
Back: The minimum number of elements for the compiler to assume `a` contains.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1728244147628-->
END%%
%%ANKI
Basic
*Why* does the following produce a compilation error?
```c
void foo(int a[3]);
int main() {
int a[] = { 1, 2 };
foo(a);
}
```
Back: N/A. It doesn't.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1728244147652-->
END%%
%%ANKI
Basic
*Why* does the following produce a compilation error?
```c
void foo(int a[static 3]);
int main() {
int a[] = { 1, 2 };
foo(a);
}
```
Back: Because the argument to `foo` does not have at least `3` elements.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1728244147655-->
END%%
%%ANKI
Basic
*Why* does the following produce a compilation error?
```c
void foo(int a[static 3]);
int main() {
int a[] = { 1, 2, 3, 4 };
foo(a);
}
```
Back: N/A. It doesn't.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1728244147658-->
END%%
%%ANKI
Basic
*Why* does the following produce a compilation error?
```c
void foo(int a[3]);
int main() {
foo(0);
}
```
Back: N/A. It doesn't.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1728244147661-->
END%%
%%ANKI
Basic
*Why* does the following produce a compilation error?
```c
void foo(int a[static 1]);
int main() {
foo(0);
}
```
Back: Because `static` indicates a valid pointer must be passed to `foo`.
Reference: “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
<!--ID: 1728244147664-->
END%%
%%ANKI
Basic
Add initializer with first element set to `1` using designated initialization.
```c
int example[3];
```
Back:
```c
int example[3] = { [0] = 1 };
```
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730757470057-->
END%%
%%ANKI
Basic
Add initializer with first element set to `1` *without* using designated initialization.
```c
int example[3];
```
Back:
```c
int example[3] = { 1 };
```
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730757470061-->
END%%
%%ANKI
Basic
What is the value of `example[1]` in the following?
```c
int example[2] = { [0] = 1 };
```
Back: `0`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730757470063-->
END%%
%%ANKI
Basic
Are arrays passed by reference or value?
Back: Reference.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730758755493-->
END%%
%%ANKI
Basic
Is the following an FLA or VLA?
```c
double a[4];
```
Back: FLA.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576008-->
END%%
%%ANKI
Basic
Is the following an FLA or VLA?
```c
double a[];
```
Back: N/A. This is invalid syntax.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576013-->
END%%
%%ANKI
Basic
Is the following an FLA or VLA?
```c
double a[] = { 0 };
```
Back: FLA.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576019-->
END%%
%%ANKI
Basic
Is the following an FLA or VLA?
```c
int n = 2;
double a[n];
```
Back: VLA.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576025-->
END%%
%%ANKI
Basic
Is the following an FLA or VLA?
```c
#define n 2
double a[n];
```
Back: FLA.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576030-->
END%%
%%ANKI
Basic
Is the following an FLA or VLA?
```c
enum { n = 2 };
double a[n];
```
Back: FLA.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576036-->
END%%
%%ANKI
Basic
Is the following an FLA or VLA?
```c
int n = 2;
double a[n] = {0};
```
Back: N/A. Variable-sized objects may not be initialized.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576041-->
END%%
Evaluation of an array `A` returns `&A[0]`, i.e. a [[#Pointers|pointer]] to the first array element. This is called **array decay**.
%%ANKI
Basic
What is the effect of array decay?
Back: Evaluation of an array `A` returns `&A[0]`.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953228-->
END%%
%%ANKI
Basic
What name is given to the implicit conversion of an array to a pointer?
Back: Array decay.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953231-->
END%%
%%ANKI
Basic
According to Gustedt, what C feature explains why are there no "array values"?
Back: Array-to-pointer decay.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953234-->
END%%
%%ANKI
Basic
Why can't arrays directly be made arguments to functions?
Back: Because array arguments decay to pointers.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953237-->
END%%
%%ANKI
Cloze
In a function declaration, any array parameter rewrites to {a pointer}.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1732551953240-->
END%%
#### Fixed-Length
A fixed-length array (FLA) has a predetermined size. Their stack allocations can be computed at compilation time.
%%ANKI
Basic
What is FLA an acronym for?
Back: **F**ixed-**l**ength **a**rray.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1731952634166-->
END%%
%%ANKI
Basic
What two ways can the length of an FLA be specified?
Back: By an ICE or an initializer.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576002-->
END%%
%%ANKI
Basic
For the following to be an FLA, what must `N` be?
```c
double a[N];
```
Back: An ICE.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576047-->
END%%
%%ANKI
Basic
*Why* must FLAs be declared within a function?
Back: N/A. They can exist elsewhere.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: x86-64
<!--ID: 1731952634167-->
END%%
#### Variable-Length
A variable-length array (VLA) has its size determined at runtime. Their stack allocations must be determined with respect to other registers available to the frame.
%%ANKI
Basic
What is VLA an acronym for?
Back: **V**ariable-**l**ength **a**rray.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1731952634168-->
END%%
%%ANKI
Basic
Where *must* a VLA be declared?
Back: Within a function.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957575996-->
END%%
%%ANKI
Basic
*Why* do variable-length arrays require use of a frame pointer?
Back: Offsets depend on how much space must be allocated on the stack.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: x86-64
<!--ID: 1731952634169-->
END%%
%%ANKI
Basic
*Why* must VLAs be declared within a function?
Back: Their implementation relies on frame pointers.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: x86-64
<!--ID: 1731952634170-->
END%%
### Structures
A `struct` is a grouping of data together. It has the following general form:
```c
struct optional_tag {
type_1 ident1;
...
type_N identN;
} optional_var1 ... optional_varM;
```
%%ANKI
Cloze
{Structures} combine items that may have different {base types}.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1727957576087-->
END%%
%%ANKI
Basic
What is the underlined portion of the following declaration called?
```c
struct ___ { ... };
```
Back: The tag.
Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
<!--ID: 1722786892126-->
END%%
%%ANKI
Basic
What distinguishes the `X`'s from one another in the following?
```c
struct X { ... } X;
```
Back: The first `X` is a tag whereas the second is a variable with type `struct X`.
Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
<!--ID: 1722786892127-->
END%%
%%ANKI
Basic
What distinguishes the `X`'s from one another in the following?
```c
typedef struct X { ... } X;
```
Back: The first `X` is a tag whereas the second is an alias for type `struct X`.
Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
<!--ID: 1722786892128-->
END%%
%%ANKI
Basic
Define an object with `fieldA` set to `1` using designated initialization.
```c
struct example { int fieldA; };
```
Back:
```c
struct example test = { .fieldA = 1 };
```
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730757470065-->
END%%
%%ANKI
Basic
Define an object with `fieldA` set to `1` *without* using designated initialization.
```c
struct example { int fieldA; };
```
Back:
```c
struct example test = { 1 };
```
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730757470066-->
END%%
%%ANKI
Basic
What is the value of `test.fieldB` in the following?
```c
struct example { int fieldA; int fieldB; };
struct example test = { .fieldA = 1 };
```
Back: `0`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730757470068-->
END%%
%%ANKI
Basic
Are `struct`s well-defined with respect to `=` (i.e. assignment)?
Back: Yes.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730758755496-->
END%%
%%ANKI
Basic
Are `struct`s well-defined with respect to `==` (i.e. equality)?
Back: No.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730758755498-->
END%%
%%ANKI
Basic
Are `struct`s well-defined with respect to `!=` (i.e. inequality)?
Back: No.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730758755499-->
END%%
%%ANKI
Basic
Generally speaking, what are valid member types of a `struct`?
Back: All object types except VLAs.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730758755500-->
END%%
%%ANKI
Basic
Generally speaking, what object type is not a valid `struct` member type?
Back: VLAs.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730758755501-->
END%%
%%ANKI
Basic
Declare a variable `var` of the nested `struct` with member `c` set to `1`.
```c
struct A {
struct B { int c; };
};
```
Back: `struct B var = { 1 };`
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730758755502-->
END%%
%%ANKI
Basic
What is the visibility of `struct B` with respect to `struct A`?
```c
struct A {
struct B { int c; };
};
```
Back: They have the same visibility.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730758755503-->
END%%
%%ANKI
Basic
What does it mean for `struct A` and `struct B` to have the same visibility?
```c
struct A {
struct B { int c; };
};
```
Back: Nesting `struct`s does not introduce any notion of scope.
Reference: Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
<!--ID: 1730758755504-->
END%%
## Unions
A `union` is a grouping of data together but with overlaid storage. It has the following general form:
```c
union optional_tag {
type1 ident1;
...
typeN identN;
} optional_var1 ... optional_varN;
```
%%ANKI
Basic
What is the underlined portion of the following declaration called?
```c
union ___ { ... };
```
Back: The tag.
Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
<!--ID: 1722786892129-->
END%%
%%ANKI
Basic
What distinguishes the `X`'s from one another in the following?
```c
union X { ... } X;
```
Back: The first `X` is a tag whereas the second is a variable with type `union X`.
Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
<!--ID: 1722786892130-->
END%%
%%ANKI
Basic
What distinguishes the `X`'s from one another in the following?
```c
typedef union X { ... } X;
```
Back: The first `X` is a tag whereas the second is an alias for type `union X`.
Reference: Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.
<!--ID: 1722786892131-->
END%%
## Pointers
Pointers are another type of derived type. They are listed in more detail [[pointers|here]].
## Functions
Functions are another type of derived type. They are listed in more detail [[c17/functions|here]].
## Bibliography
* Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
* “ISO: Programming Languages - C17,” April 2017, [https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf](https://www.open-std.org/jtc1/sc22/wg14/www/abq/c17_updated_proposed_fdis.pdf).
* Jens Gustedt, _Modern C_ (Shelter Island, NY: Manning Publications Co, 2020).
* Van der Linden, Peter. _Expert C Programming: Deep C Secrets_. Programming Languages / C. Mountain View, Cal.: SunSoft Pr, 1994.

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -856,7 +856,7 @@ END%%
%%ANKI %%ANKI
Cloze Cloze
{1:`R_X86_64_32`} is to {2:absolute} whereas {2:`R_X86_64_PC32`} is to {1:relative}. {1:`R_X86_64_32`} is to {2:absolute} whereas {2:`R_X86_64_PC32`} is to {1:PC-relative}.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: linker::elf x86-64 Tags: linker::elf x86-64
<!--ID: 1737320385860--> <!--ID: 1737320385860-->
@ -882,7 +882,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
What is the significance of `PC` in type `R_X86_64_PC32`? What is `PC` an acronym of in type `R_X86_64_PC32`?
Back: It is short for **p**rogram **c**ounter. Back: It is short for **p**rogram **c**ounter.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
Tags: c17 linker::elf x86-64 Tags: c17 linker::elf x86-64

View File

@ -1512,6 +1512,46 @@ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Pre
<!--ID: 1736702905267--> <!--ID: 1736702905267-->
END%% END%%
%%ANKI
Basic
What does $\mathop{\text{card}}\mathbb{R}$ evaluate to?
Back: $2^{\aleph_0}$
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1737422908951-->
END%%
%%ANKI
Basic
$\mathbb{R}$ is equinumerous to the power set of what?
Back: $\omega$
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1737422908963-->
END%%
%%ANKI
Basic
$\mathscr{P}(\omega)$ is equinumerous to what other well-known set?
Back: $\mathbb{R}$
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1737422908966-->
END%%
%%ANKI
Basic
What does $\mathop{\text{card}}(\mathbb{R} \times \mathbb{R})$ evaluate to?
Back: $2^{\aleph_0}$
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1737424465812-->
END%%
%%ANKI
Basic
Expression $2^{\aleph_0} \cdot 2^{\aleph_0}$ corresponds to the cardinality of what set?
Back: $\mathbb{R} \times \mathbb{R}$
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1737424465818-->
END%%
### Schröder-Bernstein Theorem ### Schröder-Bernstein Theorem
For any sets $A$ and $B$, if $A \preceq B$ and $B \preceq A$, then $A \approx B$. For any sets $A$ and $B$, if $A \preceq B$ and $B \preceq A$, then $A \approx B$.
@ -1601,6 +1641,38 @@ Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Pre
<!--ID: 1736711693550--> <!--ID: 1736711693550-->
END%% END%%
%%ANKI
Basic
Enderton proves $\mathbb{R} \approx \mathscr{P}(\omega)$ by applying the Schröder-Bernstein theorem on what two sets?
Back: $\mathbb{R}$ and $^\omega 2$.
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1737422908971-->
END%%
%%ANKI
Basic
Suppose $A \subseteq B \subseteq C$ and $A \approx C$. What theorem is used to prove $A \approx B$?
Back: The Schröder-Bernstein theorem.
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1737424465821-->
END%%
%%ANKI
Basic
Suppose $A \subseteq B \subseteq C$ and $A \approx B$. What theorem is used to prove $B \approx C$?
Back: N/A. This is not necessarily true.
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1737424465826-->
END%%
%%ANKI
Basic
Suppose $A \subseteq B \subseteq C$ and $C \approx A$. What theorem is used to prove $B \approx C$?
Back: The Schröder-Bernstein theorem.
Reference: Herbert B. Enderton, *Elements of Set Theory* (New York: Academic Press, 1977).
<!--ID: 1737424465829-->
END%%
## Hilbert's Hotel ## Hilbert's Hotel
Consider a hypothetical hotel with rooms numbered $1$, $2$, $3$, and so on with no upper limit. That is, there is a countably infinite number of rooms in this hotel. Furthermore, it's assumed every room is occupied. Consider a hypothetical hotel with rooms numbered $1$, $2$, $3$, and so on with no upper limit. That is, there is a countably infinite number of rooms in this hotel. Furthermore, it's assumed every room is occupied.

View File

@ -10,8 +10,6 @@ tags:
Trigonometry was originally derived from a Greek word meaning "triangle measuring". It has since been generalized to refer to the study of periodicity. Trigonometry was originally derived from a Greek word meaning "triangle measuring". It has since been generalized to refer to the study of periodicity.
If the real number $t$ is the directed length of an arc (either positive or negative) measured on the [[unit-circle|unit circle]] $x^2 + y^2 = 1$ (with counterclockwise as the positive direction) with initial point $\langle 1, 0 \rangle$ and terminal point $\langle x, y \rangle$, then the **cosine** of $t$, denoted $\cos(t)$, and **sine** of $t$, denoted $\sin(t)$, are defined to be $$\cos(t) = x \quad\text{and}\quad \sin(t) = y.$$
%%ANKI %%ANKI
Basic Basic
Trigonometry was originally the study of what geometric shape? Trigonometry was originally the study of what geometric shape?
@ -20,6 +18,8 @@ Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737167693405--> <!--ID: 1737167693405-->
END%% END%%
## Functions
%%ANKI %%ANKI
Basic Basic
What are the two most fundamental trigonometric functions? What are the two most fundamental trigonometric functions?
@ -28,36 +28,6 @@ Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513249--> <!--ID: 1737349513249-->
END%% END%%
%%ANKI
Cloze
The {sine} of $t$ is denoted as {$\sin(t)$}.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513250-->
END%%
%%ANKI
Cloze
The {cosine} of $t$ is denoted as {$\cos(t)$}.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513251-->
END%%
%%ANKI
Basic
Map $[0, t]$ to the unit circle. Geometrically, what does $\cos(t)$ correspond to?
Back: The $x$-coordinate of the arc's terminal point.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513252-->
END%%
%%ANKI
Basic
Map $[0, t]$ to the unit circle. Geometrically, what does $\sin(t)$ correspond to?
Back: The $y$-coordinate of the arc's terminal point.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513253-->
END%%
%%ANKI %%ANKI
Cloze Cloze
The {1:$x$}-coordinate is to {2:$\cos$} whereas the {2:$y$}-coordinate is to {1:$\sin$}. The {1:$x$}-coordinate is to {2:$\cos$} whereas the {2:$y$}-coordinate is to {1:$\sin$}.
@ -75,18 +45,38 @@ END%%
%%ANKI %%ANKI
Basic Basic
What geometric aspect of the unit circle corresponds to the input of the cosine function? Consider the following arc with length $t$ on the unit circle. With maximum specificity, what is its terminal point?
Back: Arc length. ![[example-arc.png]]
Back: $\langle \cos(t), \sin(t) \rangle$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024. Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513257--> <!--ID: 1737349513262-->
END%% END%%
%%ANKI %%ANKI
Basic Basic
What geometric aspect of the unit circle corresponds to the output of the cosine function? Why are $\sin$ and $\cos$ called circular functions?
Back: The $x$-coordinate of an arc's terminal point. Back: Their values are determined by coordinates of points on the unit circle.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024. Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513258--> <!--ID: 1737349971452-->
END%%
### Sine
If the real number $t$ is the directed length of an arc (either positive or negative) measured on the [[unit-circle|unit circle]] $x^2 + y^2 = 1$ (with counterclockwise as the positive direction) with initial point $\langle 1, 0 \rangle$ and terminal point $\langle x, y \rangle$, then the **sine** of $t$, denoted $\sin(t)$ is defined to be $$\sin(t) = y.$$
%%ANKI
Cloze
The {sine} of $t$ is denoted as {$\sin(t)$}.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513250-->
END%%
%%ANKI
Basic
Map $[0, t]$ to the unit circle. Geometrically, what does $\sin(t)$ correspond to?
Back: The $y$-coordinate of the arc's terminal point.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513253-->
END%% END%%
%%ANKI %%ANKI
@ -105,15 +95,6 @@ Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513261--> <!--ID: 1737349513261-->
END%% END%%
%%ANKI
Basic
Consider the following arc with length $t$ on the unit circle. What is the terminal point's $x$-coordinate?
![[example-arc.png]]
Back: $\cos(t)$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513260-->
END%%
%%ANKI %%ANKI
Basic Basic
Consider the following arc with length $t$ on the unit circle. What is the terminal point's $y$-coordinate? Consider the following arc with length $t$ on the unit circle. What is the terminal point's $y$-coordinate?
@ -123,47 +104,6 @@ Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513256--> <!--ID: 1737349513256-->
END%% END%%
%%ANKI
Basic
Consider the following arc with length $t$ on the unit circle. With maximum specificity, what is its terminal point?
![[example-arc.png]]
Back: $\langle \cos(t), \sin(t) \rangle$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513262-->
END%%
%%ANKI
Basic
What does $\cos(0)$ evaluate to?
Back: $1$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349971441-->
END%%
%%ANKI
Basic
What does $\cos\left(\frac{\pi}{2}\right)$ evaluate to?
Back: $0$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349971443-->
END%%
%%ANKI
Basic
What does $\cos\left(-\frac{\pi}{2}\right)$ evaluate to?
Back: $0$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349971445-->
END%%
%%ANKI
Basic
What does $\cos\left(\pi\right)$ evaluate to?
Back: $-1$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349971446-->
END%%
%%ANKI %%ANKI
Basic Basic
What does $\sin(2\pi)$ evaluate to? What does $\sin(2\pi)$ evaluate to?
@ -198,10 +138,165 @@ END%%
%%ANKI %%ANKI
Basic Basic
Why are $\sin$ and $\cos$ called circular functions? What is the domain of $\sin$?
Back: Their values are determined by coordinates of points on the unit circle. Back: $\mathbb{R}$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024. Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349971452--> <!--ID: 1737349971455-->
END%%
%%ANKI
Basic
What is the range of $\sin$?
Back: $[-1, 1]$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349971456-->
END%%
%%ANKI
Basic
Let $t$ be the length of an arc with initial point $\langle 1, 0 \rangle$ and terminal point in quadrant I. What is the sign of $\sin(t)$?
Back: $\sin(t) > 0$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737416715565-->
END%%
%%ANKI
Basic
Let $t$ be the length of an arc with initial point $\langle 1, 0 \rangle$ and terminal point in quadrant II. What is the sign of $\sin(t)$?
Back: $\sin(t) > 0$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737416715568-->
END%%
%%ANKI
Basic
Let $t$ be the length of an arc with initial point $\langle 1, 0 \rangle$ and terminal point in quadrant III. What is the sign of $\sin(t)$?
Back: $\sin(t) < 0$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737416715575-->
END%%
%%ANKI
Basic
Let $t$ be the length of an arc with initial point $\langle 1, 0 \rangle$ and terminal point in quadrant IV. What is the sign of $\sin(t)$?
Back: $\sin(t) < 0$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737416715578-->
END%%
%%ANKI
Basic
Let $t$ be the length of an arc with initial point $\langle 1, 0 \rangle$. When is $\sin(t) > 0$?
Back: When the terminal point of the arc is in quadrant I or II.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737416715588-->
END%%
%%ANKI
Basic
Let $t$ be the length of an arc with initial point $\langle 1, 0 \rangle$. When is $\sin(t) < 0$?
Back: When the terminal point of the arc is in quadrant III or IV.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737416715591-->
END%%
%%ANKI
Basic
Let $\frac{\pi}{2} < t < \pi$. What is the sign of $\sin(t)$?
Back: Positive.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737417172718-->
END%%
%%ANKI
Basic
Let $\frac{3\pi}{2} < t < 2\pi$. What is the sign of $\sin(t)$?
Back: Negative.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737417172722-->
END%%
%%ANKI
Cloze
For any real number $t$, {$\sin^2(t)$} is alternatively denoted as {$(\sin(t))^2$}.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737418825316-->
END%%
### Cosine
If the real number $t$ is the directed length of an arc (either positive or negative) measured on the [[unit-circle|unit circle]] $x^2 + y^2 = 1$ (with counterclockwise as the positive direction) with initial point $\langle 1, 0 \rangle$ and terminal point $\langle x, y \rangle$, then the **cosine** of $t$, denoted $\cos(t)$, is defined to be $$\cos(t) = x.$$
%%ANKI
Cloze
The {cosine} of $t$ is denoted as {$\cos(t)$}.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513251-->
END%%
%%ANKI
Basic
Map $[0, t]$ to the unit circle. Geometrically, what does $\cos(t)$ correspond to?
Back: The $x$-coordinate of the arc's terminal point.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513252-->
END%%
%%ANKI
Basic
What geometric aspect of the unit circle corresponds to the input of the cosine function?
Back: Arc length.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513257-->
END%%
%%ANKI
Basic
What geometric aspect of the unit circle corresponds to the output of the cosine function?
Back: The $x$-coordinate of an arc's terminal point.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513258-->
END%%
%%ANKI
Basic
Consider the following arc with length $t$ on the unit circle. What is the terminal point's $x$-coordinate?
![[example-arc.png]]
Back: $\cos(t)$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349513260-->
END%%
%%ANKI
Basic
What does $\cos(0)$ evaluate to?
Back: $1$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349971441-->
END%%
%%ANKI
Basic
What does $\cos\left(\frac{\pi}{2}\right)$ evaluate to?
Back: $0$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349971443-->
END%%
%%ANKI
Basic
What does $\cos\left(-\frac{\pi}{2}\right)$ evaluate to?
Back: $0$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349971445-->
END%%
%%ANKI
Basic
What does $\cos\left(\pi\right)$ evaluate to?
Back: $-1$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349971446-->
END%% END%%
%%ANKI %%ANKI
@ -222,18 +317,111 @@ END%%
%%ANKI %%ANKI
Basic Basic
What is the domain of $\sin$? Let $t$ be the length of an arc with initial point $\langle 1, 0 \rangle$ and terminal point in quadrant I. What is the sign of $\cos(t)$?
Back: $\mathbb{R}$ Back: $\cos(t) > 0$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024. Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349971455--> <!--ID: 1737416715551-->
END%% END%%
%%ANKI %%ANKI
Basic Basic
What is the range of $\sin$? Let $t$ be the length of an arc with initial point $\langle 1, 0 \rangle$ and terminal point in quadrant II. What is the sign of $\cos(t)$?
Back: $[-1, 1]$ Back: $\cos(t) < 0$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024. Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737349971456--> <!--ID: 1737416715557-->
END%%
%%ANKI
Basic
Let $t$ be the length of an arc with initial point $\langle 1, 0 \rangle$ and terminal point in quadrant III. What is the sign of $\cos(t)$?
Back: $\cos(t) < 0$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737416715560-->
END%%
%%ANKI
Basic
Let $t$ be the length of an arc with initial point $\langle 1, 0 \rangle$ and terminal point in quadrant IV. What is the sign of $\cos(t)$?
Back: $\cos(t) < 0$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737416715562-->
END%%
%%ANKI
Basic
Let $t$ be the length of an arc with initial point $\langle 1, 0 \rangle$. When is $\cos(t) > 0$?
Back: When the terminal point of the arc is in quadrant I or IV.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737416715582-->
END%%
%%ANKI
Basic
Let $t$ be the length of an arc with initial point $\langle 1, 0 \rangle$. When is $\cos(t) < 0$?
Back: When the terminal point of the arc is in quadrant II or III.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737416715585-->
END%%
%%ANKI
Basic
Let $\frac{\pi}{2} < t < \pi$. What is the sign of $\cos(t)$?
Back: Negative.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737417172726-->
END%%
%%ANKI
Basic
Let $\frac{3\pi}{2} < t < 2\pi$. What is the sign of $\cos(t)$?
Back: Positive.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737417172730-->
END%%
%%ANKI
Cloze
For any real number $t$, {$\cos^2(t)$} is alternatively denoted as {$(\cos(t))^2$}.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737418825321-->
END%%
## Identities
### Pythagorean Identity
For any real number $t$, $$\cos^2(t) + \sin^2(t) = 1.$$
%%ANKI
Basic
Which trigonometric identity is often considered the most important?
Back: The Pythagorean Identity.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737418825324-->
END%%
%%ANKI
Basic
What does the Pytagorean Identity state?
Back: For any real number $t$, $\cos^2(t) + \sin^2(t) = 1$.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737418825326-->
END%%
%%ANKI
Basic
What shape is used to derive the Pythagorean Identity?
Back: The unit circle.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737418825329-->
END%%
%%ANKI
Basic
How is the Pythagorean Identity derived?
Back: By applying the Pythagorean Theorem on point $\langle \cos(t), \sin(t) \rangle$ on the unit circle.
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737418825332-->
END%% END%%
## Bibliography ## Bibliography

View File

@ -203,7 +203,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
What arc describes the portion of a unit circle found in the first quadrant? What interval maps to the portion of a unit circle found in the first quadrant?
Back: $\left(0, \frac{\pi}{2}\right)$ Back: $\left(0, \frac{\pi}{2}\right)$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024. Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737347029839--> <!--ID: 1737347029839-->
@ -211,7 +211,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
What arc describes the portion of a unit circle found in the third quadrant? What interval maps to the portion of a unit circle found in the third quadrant?
Back: $\left(\pi, \frac{3\pi}{2}\right)$ Back: $\left(\pi, \frac{3\pi}{2}\right)$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024. Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737347029841--> <!--ID: 1737347029841-->
@ -219,7 +219,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
What arc describes the portion of a unit circle found in the fourth quadrant? What interval maps to the portion of a unit circle found in the fourth quadrant?
Back: $\left(\frac{3\pi}{2}, 2\pi\right)$ Back: $\left(\frac{3\pi}{2}, 2\pi\right)$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024. Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737347029843--> <!--ID: 1737347029843-->
@ -227,7 +227,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
What arc describes the portion of a unit circle found in the second quadrant? What interval maps to the portion of a unit circle found in the second quadrant?
Back: $\left(\frac{\pi}{2}, \pi\right)$ Back: $\left(\frac{\pi}{2}, \pi\right)$
Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024. Reference: Ted Sundstrom and Steven Schlicker, _Trigonometry_, 2024.
<!--ID: 1737347029844--> <!--ID: 1737347029844-->

View File

@ -562,7 +562,7 @@ END%%
%%ANKI %%ANKI
Basic Basic
How many registers are designated as callee-saved? How many registers are designated as callee-saved?
Back: 6. Back: Six.
Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016. Reference: Bryant, Randal E., and David O'Hallaron. *Computer Systems: A Programmer's Perspective*. Third edition, Global edition. Always Learning. Pearson, 2016.
<!--ID: 1730121604414--> <!--ID: 1730121604414-->
END%% END%%