Footnotes


  1. https://www.ioccc.org/↩︎

  2. https://en.wikipedia.org/wiki/Python_(programming_language)↩︎

  3. https://en.wikipedia.org/wiki/JavaScript↩︎

  4. https://en.wikipedia.org/wiki/Java_(programming_language)↩︎

  5. https://en.wikipedia.org/wiki/Rust_(programming_language)↩︎

  6. https://en.wikipedia.org/wiki/Go_(programming_language)↩︎

  7. https://en.wikipedia.org/wiki/Swift_(programming_language)↩︎

  8. https://en.wikipedia.org/wiki/Objective-C↩︎

  9. https://en.wikipedia.org/wiki/ANSI_C↩︎

  10. https://en.wikipedia.org/wiki/POSIX↩︎

  11. https://visualstudio.microsoft.com/vs/community/↩︎

  12. https://docs.microsoft.com/en-us/windows/wsl/install-win10↩︎

  13. https://developer.apple.com/xcode/↩︎

  14. https://beej.us/guide/bgc/↩︎

  15. https://en.cppreference.com/↩︎

  16. https://groups.google.com/g/comp.lang.c↩︎

  17. https://www.reddit.com/r/C_Programming/↩︎

  18. https://en.wikipedia.org/wiki/Assembly_language↩︎

  19. https://en.wikipedia.org/wiki/Bare_machine↩︎

  20. https://en.wikipedia.org/wiki/Operating_system↩︎

  21. https://en.wikipedia.org/wiki/Embedded_system↩︎

  22. https://en.wikipedia.org/wiki/Rust_(programming_language)↩︎

  23. https://en.wikipedia.org/wiki/Grok↩︎

  24. I know someone will fight me on that, but it’s gotta be at least in the top three, right?↩︎

  25. Well, technically there are more than two, but hey, let’s pretend there are two—ignorance is bliss, right?↩︎

  26. https://en.wikipedia.org/wiki/Assembly_language↩︎

  27. https://en.wikipedia.org/wiki/Machine_code↩︎

  28. Technically, it contains preprocessor directives and function prototypes (more on that later) for common input and output needs.↩︎

  29. https://en.wikipedia.org/wiki/Unix↩︎

  30. If you don’t give it an output filename, it will export to a file called a.out by default—this filename has its roots deep in Unix history.↩︎

  31. A “byte” is an 8-bit binary number. Think of it as an integer that can only hold the values from 0 to 255, inclusive.↩︎

  32. I’m seriously oversimplifying how modern memory works, here. But the mental model works, so please forgive me.↩︎

  33. Read this as “pointer to a char” or “char pointer”. “Char” for character. Though I can’t find a study, it seems anecdotally most people pronounce this as “char”, a minority say “car”, and a handful say “care”. We’ll talk more about pointers later.↩︎

  34. Colloquially, we say they have “random” values, but they aren’t truly—or even pseudo-truly—random numbers.↩︎

  35. This isn’t strictly 100% true. When we get to learning about static storage duration, you’ll find the some variables are initialized to zero automatically. But the safe thing to do is always initialize them.↩︎

  36. The _t is short for type.↩︎

  37. Except for with variable length arrays—but that’s a story for another time.↩︎

  38. This was considered such a hazard that the designers of the Go Programming Language made break the default; you have to explicitly use Go’s fallthrough statement if you want to fall into the next case.↩︎

  39. Never say “never”.↩︎

  40. Typically. I’m sure there are exceptions out there in the dark corridors of computing history.↩︎

  41. A byte is a number made up of no more than 8 binary digits, or bits for short. This means in decimal digits just like grandma used to use, it can hold an unsigned number between 0 and 255, inclusive.↩︎

  42. The order that bytes come in is referred to as the endianness of the number. Common ones are big endian and little endian. This usually isn’t something you need to worry about.↩︎

  43. That is, base 16 with digits 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F.↩︎

  44. That’s not all! It’s used in /*comments*/ and multiplication and in function prototypes with variable length arrays! It’s all the same *, but the context gives it different meaning.↩︎

  45. https://en.wikipedia.org/wiki/Null_pointer#History↩︎

  46. https://en.wikipedia.org/wiki/Sentinel_value↩︎

  47. The pointer type variables are a, d, f, and i, because those are the ones with * in front of them.↩︎

  48. These days, anyway.↩︎

  49. Again, not really, but variable-length arrays—of which I’m not really a fan—are a story for another time.↩︎

  50. Since arrays are just pointers to the first element of the array under the hood, there’s no additional information recording the length.↩︎

  51. Because when you pass an array to a function, you’re actually just passing a pointer to the first element of that array, not the “entire” array.↩︎

  52. In the good old MS-DOS days before memory protection was a thing, I was writing some particularly abusive C code that deliberately engaged in all kinds of undefined behavior. But I knew what I was doing, and things were working pretty well. Until I made a misstep that caused a lockup and, as I found upon reboot, nuked all my BIOS settings. That was fun. (Shout-out to @man for those fun times.)↩︎

  53. There are a lot of things that cause undefined behavior, not just out-of-bounds array accesses. This is what makes the C language so exciting.↩︎

  54. This is technically incorrect, as a pointer to an array and a pointer to the first element of an array have different types. But we can burn that bridge when we get to it.↩︎

  55. C11 §6.7.6.2¶1 requires it be greater than zero. But you might see code out there with arrays declared of zero length at the end of structs and GCC is particularly lenient about it unless you compile with -pedantic. This zero-length array was a hackish mechanism for making variable-length structures. Unfortunately, it’s technically undefined behavior to access such an array even though it basically worked everywhere. C99 codified a well-defined replacement for it called flexible array members, which we’ll chat about later.↩︎

  56. This is also equivalent: void print_2D_array(int (*a)[3]), but that’s more than I want to get into right now.↩︎

  57. Though it is true that C doesn’t track the length of strings.↩︎

  58. If you’re using the basic character set or an 8-bit character set, you’re used to one character being one byte. This isn’t true in all character encodings, though.↩︎

  59. This is different than the NULL pointer, and I’ll abbreviate it NUL when talking about the character versus NULL for the pointer.↩︎

  60. Later we’ll learn a neater way to do it with pointer arithmetic.↩︎

  61. There’s a safer function called strncpy() that you should probably use instead, but we’ll get to that later.↩︎

  62. Although in C individual items in memory like ints are referred to as “objects”, they’re not objects in an object-oriented programming sense.↩︎

  63. The Saturn was a popular brand of economy car in the United States until it was put out of business by the 2008 crash, sadly so to us fans.↩︎

  64. A pointer is likely 8 bytes on a 64-bit system.↩︎

  65. A deep copy follows pointer in the struct and copies the data they point to, as well. A shallow copy just copies the pointers, but not the things they point to. C doesn’t come with any built-in deep copy functionality.↩︎

  66. https://stackoverflow.com/questions/141720/how-do-you-compare-structs-for-equality-in-c↩︎

  67. We used to have three different newlines in broad effect: Carriage Return (CR, used on old Macs), Linefeed (LF, used on Unix systems), and Carriage Return/Linefeed (CRLF, used on Windows systems). Thankfully the introduction of OS X, being Unix-based, reduced this number to two.↩︎

  68. If the buffer’s not big enough to read in an entire line, it’ll just stop reading mid-line, and the next call to fgets() will continue reading the rest of the line.↩︎

  69. Normally the second program would read all the bytes at once, and then print them out in a loop. That would be more efficient. But we’re going for demo value, here.↩︎

  70. https://en.wikipedia.org/wiki/Hex_dump↩︎

  71. https://en.wikipedia.org/wiki/Endianess↩︎

  72. And this is why I used individual bytes in my fwrite() and fread() examples, above, shrewdly.↩︎

  73. https://en.wikipedia.org/wiki/Protocol_buffers↩︎

  74. We’ll talk more about these later.↩︎

  75. Recall that the sizeof operator tells you the size in bytes of an object in memory.↩︎

  76. Or string, which is really an array of chars. Somewhat peculiarly, you can also have a pointer that references one past the end of the array without a problem and still do math on it. You just can’t dereference it when it’s out there.↩︎

  77. Because remember that array notation is just a dereference and some pointer math, and you can’t dereference a void*!↩︎

  78. You can also cast the void* to another type, but we haven’t gotten to casts yet.↩︎

  79. Or until the program exits, in which case all the memory allocated by it is freed. Asterisk: some systems allow you to allocate memory that persists after a program exits, but it’s system dependent, out of scope for this guide, and you’ll certainly never do it on accident.↩︎

  80. http://www.open-std.org/jtc1/sc22/wg14/www/docs/summary.htm#dr_460↩︎

  81. https://en.wikipedia.org/wiki/Bit_bucket↩︎

  82. “Bit” is short for binary digit. Binary is just another way of representing numbers. Instead of digits 0-9 like we’re used to, it’s digits 0-1.↩︎

  83. https://en.wikipedia.org/wiki/Two%27s_complement↩︎

  84. The industry term for a sequence of exactly, indisputably 8 bits is an octet.↩︎

  85. In general, f you have an \(n\) bit two’s complement number, the signed range is \(-2^{n-1}\) to \(2^{n-1}-1\). And the unsigned range is \(0\) to \(2^n-1\).↩︎

  86. https://en.wikipedia.org/wiki/ASCII↩︎

  87. https://en.wikipedia.org/wiki/List_of_information_system_character_sets↩︎

  88. https://en.wikipedia.org/wiki/Unicode↩︎

  89. Depends on if a char defaults to signed char or unsigned char↩︎

  90. https://en.wikipedia.org/wiki/Signed_number_representations#Signed_magnitude_representation↩︎

  91. My char is signed.↩︎

  92. https://en.wikipedia.org/wiki/IEEE_754↩︎

  93. This program runs as its comments indicate on a system with FLT_DIG of 6 that uses IEEE-754 base-2 floating point numbers. Otherwise, you might get different output.↩︎

  94. It’s really surprising to me that C doesn’t have this in the spec yet. In the C99 Rationale document, they write, “A proposal to add binary constants was rejected due to lack of precedent and insufficient utility.” Which seems kind of silly in light of some of the other features they kitchen-sinked in there! I’ll bet one of the next releases has it.↩︎

  95. https://en.wikipedia.org/wiki/Scientific_notation↩︎

  96. They’re the same except snprintf() allows you to specify a maximum number of bytes to output, preventing the overrunning of the end of your string. So it’s safer.↩︎

  97. https://en.wikipedia.org/wiki/ASCII↩︎

  98. We have to pass a pointer to badchar to strtoul() or it won’t be able to modify it in any way we can see, analogous to why you have to pass a pointer to an int to a function if you want that function to be able to change that value of that int.↩︎

  99. In practice, what’s probably happening on your implementation is that the high-order bits are just being dropped from the result, so a 16-bit number 0x1234 being converted to an 8-bit number ends up as 0x0034, or just 0x34.↩︎

  100. Again, in practice, what will likely happen on your system is that the bit pattern for the original will be truncated and then just used to represent the signed number, two’s complement. For example, my system takes an unsigned char of 192 and converts it to signed char -64. In two’s complement, the bit pattern for both these numbers is binary 11000000.↩︎

  101. Not really—it’s just discarded regularly.↩︎

  102. Functions with a variable number of arguments.↩︎

  103. This is rarely done because the compiler will complain and having a prototype is the Right Thing to do. I think this still works for historic reasons, before prototypes were a thing.↩︎

  104. https://gustedt.wordpress.com/2010/08/17/a-common-misconsception-the-register-keyword/↩︎

  105. https://en.wikipedia.org/wiki/Processor_register↩︎

  106. https://en.wikipedia.org/wiki/Boids↩︎

  107. Historially, MS-DOS and Windows programs would do this differently than Unix. In Unix, the shell would expand the wildcard into all matching files before your program saw it, whereas the Microsoft variants would pass the wildcard expression into the program to deal with. In any case, there are arguments that get passed into the program.↩︎

  108. Since they’re just regular parameter names, you don’t actually have to call them argc and argv. But it’s so very idiomatic to use those names, if you get creative, other C programmers will look at you with a suspicious eye, indeed!↩︎

  109. ps, Process Status, is a Unix command to see what processes are running at the moment.↩︎

  110. https://en.wikipedia.org/wiki/Inception↩︎

  111. https://en.wikipedia.org/wiki/Shell_(computing)↩︎

  112. In Windows cmd.exe, type echo %errorlevel%. In PowerShell, type $LastExitCode.↩︎

  113. If you need a numeric value, convert the string with something like atoi() or strtol().↩︎

  114. In Windows CMD.EXE, use set FROTZ=value. In PowerShell, use $Env:FROTZ=value.↩︎

  115. https://pubs.opengroup.org/onlinepubs/9699919799/functions/exec.html↩︎

  116. You can’t always just wrap the code in /* */ comments because those won’t nest.↩︎

  117. This isn’t really a macro—it’s technically an identifier. But it’s the only predefined identifier and it feels very macro-like, so I’m including it here. Like a rebel.↩︎

  118. A hosted implementation basically means you’re running the full C standard, probably on an operating system of some kind. Which you probably are. If you’re running on bare metal in some kind of embedded system, you’re probably on a standalone implementation.↩︎

  119. OK, I know that was a cop-out answer. Basically there’s an optional extension compilers can implement wherein they agree to limit certain types of undefined behavior so that the C code is more amenable to static code analysis. It is unlikely you’ll need to use this.↩︎

  120. Breakin’ the law… breakin’ the law…↩︎

  121. https://www.openmp.org/↩︎

  122. Technically we say that it has an incomplete type.↩︎

  123. Though some compilers have options to force this to occur—search for __attribute__((packed)) to see how to do this with GCC.↩︎

  124. Assuming 8-bit chars, i.e. CHAR_BIT == 8.↩︎

  125. https://en.wikipedia.org/wiki/Type_punning↩︎

  126. I just made up that number, but it’s probably not far off↩︎

  127. There’s some devil in the details with values that are stored in registers only, but we can safely ignore that for our purposes here. Also the C spec makes no stance on these “register” things beyond the register keyword, the description for which doesn’t mention registers.↩︎

  128. You’re very likely to get different numbers on yours.↩︎

  129. There is absolutely nothing in the spec that says this will always work this way, but it happens to work this way on my system.↩︎

  130. Even if E is NULL, it turns out, weirdly.↩︎

  131. Your C compiler is not required to add padding bytes, and the values of any padding bytes that are added are indeterminate.↩︎

  132. This will vary depending on the architecture, but my system is little endian, which means the least-significant byte of the number is stored first. Big endian systems will have the 12 first and the 78 last. But the spec doesn’t dictate anything about this representation.↩︎

  133. It’s an optional feature, so it might not be there—but it probably is.↩︎

  134. I’m printing out the 16-bit values reversed since I’m on a little-endian machine at it makes it easier to read here.↩︎

  135. Assuming they point to the same array object.↩︎

  136. The Go Programming Language drew its type declaration syntax inspiration from the opposite of what C does.↩︎

  137. Not that other languages don’t do this—they do. It is interesting how many modern languages use the same operators for bitwise that C does.↩︎

  138. https://en.wikipedia.org/wiki/Bitwise_operation↩︎

  139. That is, us lowly developers aren’t supposed to know what’s in there or what it means. The spec doesn’t dictate what it is in detail.↩︎

  140. Honestly, it would be possible to remove that limitation from the language, but the idea is that the macros va_start(), va_arg(), and va_end() should be able to be written in C. And to make that happen, we need some way to initialize a pointer to the location of the first parameter. And to do that, we need the name of the first parameter. It would require a language extension to make this possible, and so far the committee hasn’t found a rationale for doing so.↩︎

  141. “This planet has—or rather had—a problem, which was this: most of the people living on it were unhappy for pretty much of the time. Many solutions were suggested for this problem, but most of these were largely concerned with the movement of small green pieces of paper, which was odd because on the whole it wasn’t the small green pieces of paper that were unhappy.” —The Hitchhiker’s Guide to the Galaxy, Douglas Adams↩︎

  142. Remember that char is just a byte-sized integer.↩︎

  143. Except for isdigit() and isxdigit().↩︎

  144. For example, we could store the code point in a big-endian 32-bit integer. Straightforward! We just invented an encoding! Actually not; that’s what UTF-32BE encoding is. Oh well—back to the grind!↩︎

  145. Ish. Technically, it’s variable width—there’s a way to represent code points higher than \(2^{16}\) by putting two UTF-16 characters together.↩︎

  146. There’s a special character called the Byte Order Mark (BOM), code point 0xFEFF, that can optionally precede the data stream and indicate the endianess. It is not required, however.↩︎

  147. Again, this is only true in UTF-16 for characters that fit in two bytes.↩︎

  148. https://en.wikipedia.org/wiki/UTF-8↩︎

  149. https://www.youtube.com/watch?v=MijmeoH9LT4↩︎

  150. Presumably the compiler makes the best effort to translate the code point to whatever the output encoding is, but I can’t find any guarantees in the spec.↩︎

  151. With a format specifier like "%s.12", for example.↩︎

  152. wcscoll() is the same as wcsxfrm() followed by wcscmp().↩︎

  153. Ish—things get funky with multi-char16_t UTF-16 encodings.↩︎

  154. https://en.wikipedia.org/wiki/Iconv↩︎

  155. http://site.icu-project.org/↩︎

  156. https://en.wikipedia.org/wiki/Core_dump↩︎

  157. Apparently it doesn’t do Unix-style signals at all deep down, and they’re simulated for console apps.↩︎

  158. Confusingly, sig_atomic_t predates the lock-free atomics and is not the same thing.↩︎

  159. If sig_action_t is signed, the range will be at least -127 to 127. If unsigned, at least 0 to 255.↩︎

  160. This is due to how VLAs are typically allocated on the stack, whereas static variables are on the heap. And the whole idea with VLAs is they’ll be automatically dellocated when the stack frame is popped at the end of the function.↩︎

  161. https://en.wikipedia.org/wiki/Goto#Criticism↩︎

  162. I’d like to point out that using goto in all these cases is avoidable. You can use variables and loops intead. It’s just that some people think goto produces the best code in those circumstances.↩︎

  163. https://en.wikipedia.org/wiki/Tail_call↩︎

  164. Which isn’t quite the same, since it’s an array, not a pointer to an int.↩︎

  165. A variable used here is an expression.↩︎

  166. Both “stack pointer” and “program counter” are related to the underlying architecture and C implementation, and are not part of the spec.↩︎

  167. The rationale here is that the program might store a value temporarily in a CPU register while it’s doing work on it. In that timeframe, the register holds the correct value, and the value on the stack might be out of date. Then later the register values would get overwritten and the changes to the variable lost.↩︎

  168. That is, remain allocated until the program ends with no way to free it.↩︎

  169. This works because in C, pointers are the same size regardless of the type of data they point to. So the compiler doesn’t need to know the size of the struct node at this point; it just needs to know the size of a pointer.↩︎

  170. https://en.wikipedia.org/wiki/Complex_number↩︎

  171. This was a harder one to research, and I’ll take any more information anyone can give me. I could be defined as _Complex_I or _Imaginary_I, if the latter exists. _Imaginary_I will handle signed zeros, but _Complex_I might not. This has implications with branch cuts and other complex-numbery-mathy things. Maybe. Can you tell I’m really getting out of my element here? In any case, the CMPLX() macros behave as if I were defined as _Imaginary_I, with signed zeros, even if _Imaginary_I doesn’t exist on the system.↩︎

  172. The simplicity of this statement doesn’t do justice to the incredible amount of work that goes into simply understanding how floating point actually functions. https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/↩︎

  173. This is the only one that doesn’t begin with an extra leading c, strangely.↩︎

  174. Some architectures have different sized data that the CPU and RAM can operate with at a faster rate than others. In those cases, if you need the fastest 8-bit number, it might give you have a 16- or 32-bit type instead because that’s just faster. So with this, you won’t know how big the type is, but it will be least as big as you say.↩︎

  175. Namely, the system has 8, 16, 32, or 64 bit integers with no padding that use two’s complement representation, in which case the intN_t variant for that particular number of bits must be defined.↩︎

  176. On Earth, anyway. Who know what crazy systems they use out there↩︎

  177. OK, don’t murder me! GMT is technically a timezone while UTC is a global time system. Also some countries might adjust GMT for daylight saving time, whereas UTC is never adjusted for daylight saving time.↩︎

  178. Admittedly, there are more than two.↩︎

  179. https://en.wikipedia.org/wiki/Unix_time↩︎

  180. You will on POSIX, where time_t is definitely an integer. Unfortunately the entire world isn’t POSIX, so there we are.↩︎

  181. https://en.wikipedia.org/wiki/POSIX_Threads↩︎

  182. I’m more a fan of shared-nothing, myself, and my skills with classic multithreading constructs are rusty, to say the least.↩︎

  183. Yes, pthreads with a “p”. It’s short for POSIX threads, a library that C11 borrowed liberally from for its threads implementation.↩︎

  184. Per §7.1.4¶5.↩︎

  185. Unless you thrd_detach(). More on this later.↩︎

  186. Though I don’t think they have to be. It’s just that the threads don’t seem to get rescheduled until some system call like might happen with a printf()… which is why I have the printf() in there.↩︎

  187. Short for “mutual exclusion”, AKA a “lock” on a section of code that only one thread is permitted to execute.↩︎

  188. That is, your process will go to sleep.↩︎

  189. You might have expected it to be “time from now”, but you’d just like to think that, wouldn’t you!↩︎

  190. And that’s why they’re called condition variables!↩︎

  191. I’m not saying it’s aliens… but it’s aliens. OK, really more likely another thread might have been woken up and gotten to the work first.↩︎

  192. Survival of the fittest! Right? I admit it’s actually nothing like that.↩︎

  193. The __STDC_VERSION__ macro didn’t exist in early C89, so if you’re worried about that, check it with #ifdef.↩︎

  194. The reason for this is when optimized, my compiler has put the value of x in a register to make the while loop fast. But the register has no way of knowing that the variable was updated in another thread, so it never sees the 3490. This isn’t really related to the all-or-nothing part of atomicity, but is more related to the synchronization aspects in the next section.↩︎

  195. Until I say otherwise, I’m speaking generally about sequentially consistent operations. More on what that means soon.↩︎

  196. Sanest from a programmer perspective.↩︎

  197. Apparently C++23 is adding this as a macro.↩︎

  198. The spec notes that they might differ in size, representation, and alignment.↩︎

  199. I just pulled that example out of nowhere. Maybe it doesn’t matter on Intel/AMD, but it could matter somewhere, dangit!↩︎

  200. C++ elaborates that if the signal is the result of a call to raise(), it is sequenced after the raise().↩︎

  201. https://en.wikipedia.org/wiki/Test-and-set↩︎

  202. Because consume is all about the operations that are dependent on the value of the acquired atomic variable, and there is no atomic variable with a fence.↩︎

  203. https://channel9.msdn.com/Shows/Going+Deep/Cpp-and-Beyond-2012-Herb-Sutter-atomic-Weapons-1-of-2↩︎

  204. https://channel9.msdn.com/Shows/Going+Deep/Cpp-and-Beyond-2012-Herb-Sutter-atomic-Weapons-2-of-2↩︎

  205. https://preshing.com/archives/↩︎

  206. https://preshing.com/20120612/an-introduction-to-lock-free-programming/↩︎

  207. https://preshing.com/20120913/acquire-and-release-semantics/↩︎

  208. https://preshing.com/20130702/the-happens-before-relation/↩︎

  209. https://preshing.com/20130823/the-synchronizes-with-relation/↩︎

  210. https://preshing.com/20140709/the-purpose-of-memory_order_consume-in-cpp11/↩︎

  211. https://preshing.com/20150402/you-can-do-any-kind-of-atomic-read-modify-write-operation/↩︎

  212. https://en.cppreference.com/w/c/atomic/memory_order↩︎

  213. https://en.cppreference.com/w/c/language/atomic↩︎

  214. https://docs.microsoft.com/en-us/windows/win32/dxtecharts/lockless-programming↩︎

  215. https://www.reddit.com/r/C_Programming/↩︎

  216. You can do this with -O on the command line.↩︎

  217. https://en.wikipedia.org/wiki/Data_structure_alignment↩︎

  218. https://en.wikipedia.org/wiki/Complex_conjugate↩︎

  219. https://en.wikipedia.org/wiki/Riemann_sphere↩︎

  220. Really it’s just required to be a modifiable lvalue, so not necessarily a variable. But you can treat it as such.↩︎

  221. https://man.archlinux.org/man/errno.3.en↩︎

  222. https://docs.microsoft.com/en-us/cpp/c-runtime-library/errno-constants?view=msvc-160↩︎

  223. https://en.wikipedia.org/wiki/Subnormal_number↩︎

  224. The minimum value of an unsigned char is 0. Same fo an unsigned short and unsigned long. Or any unsigned type, for that matter.↩︎

  225. https://en.wikipedia.org/wiki/Two%27s_complement↩︎

  226. Remember that char is just a byte-sized integer.↩︎

  227. Though the system defines MATH_ERRNO as 1 and MATH_ERREXCEPT as 2, it’s best to always use their symbolic names. Just in case.↩︎

  228. https://en.wikipedia.org/wiki/Denormal_number↩︎

  229. This is on my system. Some systems will have different points at which numbers become subnormal, or they might not support subnormal values at all.↩︎

  230. https://en.wikipedia.org/wiki/E_(mathematical_constant)↩︎

  231. https://en.wikipedia.org/wiki/Denormal_number↩︎

  232. https://en.wikipedia.org/wiki/Pythagorean_theorem↩︎

  233. https://en.wikipedia.org/wiki/Error_function↩︎

  234. https://en.wikipedia.org/wiki/Error_function↩︎

  235. https://en.wikipedia.org/wiki/Gamma_function↩︎

  236. https://en.wikipedia.org/wiki/Gamma_function↩︎

  237. https://en.cppreference.com/w/c/numeric/math/remquo↩︎

  238. https://en.cppreference.com/w/c/numeric/math/remquo↩︎

  239. A quiet NaN is one that doesn’t raise any exceptions.↩︎

  240. https://man.archlinux.org/man/sigaction.2.en↩︎

  241. As if might be sent from Unix’s kill command.]↩︎

  242. https://en.wikipedia.org/wiki/Data_structure_alignment↩︎

  243. Maybe it depends on the run-time environment and can’t be known at compile-time.↩︎

  244. https://en.cppreference.com/w/cpp/atomic/ATOMIC_VAR_INIT↩︎

  245. http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p1138r0.pdf↩︎

  246. This effectively does the same thing, but it’s clearly not atomic.↩︎

  247. The spec says, “This spurious failure enables implementation of compare-and-exchange on a broader class of machines, e.g. load-locked store-conditional machines.” And adds, “When a compare-and-exchange is in a loop, the weak version will yield better performance on some platforms. When a weak compare-and-exchange would require a loop and a strong one would not, the strong one is preferable.”↩︎

  248. Don’t use this unless you know what you’re doing—use the thread mutex functionality instead. It’ll let your blocked thread sleep and stop chewing up CPU.↩︎

  249. Don’t use this unless you know what you’re doing—use the thread mutex functionality instead. It’ll let your blocked thread sleep and stop chewing up CPU.↩︎

  250. https://en.wikipedia.org/wiki/Data_structure_alignment↩︎

  251. https://man.archlinux.org/man/unlinkat.2.en#DESCRIPTION↩︎

  252. https://man.archlinux.org/man/mkstemp.3.en↩︎

  253. https://nee.lv/2021/02/28/How-I-cut-GTA-Online-loading-times-by-70/↩︎

  254. https://stackoverflow.com/questions/17017331/c99-vscanf-for-dummies/17018046#17018046↩︎

  255. http://man.cat-v.org/unix-1st/3/atof↩︎

  256. http://man.cat-v.org/unix-1st/3/atoi↩︎

  257. https://en.wikipedia.org/wiki/Radix↩︎

  258. https://stackoverflow.com/questions/10984974/why-do-people-say-there-is-modulo-bias-when-using-a-random-number-generator↩︎

  259. https://mumble.net/~campbell/2014/04/28/uniform-random-float↩︎

  260. https://www.gnu.org/software/gsl/doc/html/rng.html↩︎

  261. Minecraft enthusiasts might recall that when generating a new world, they were given the option to enter a random number seed. That single value is used to generate that entire random world. And if your friend starts a world with the same seed you did, they’ll get the same world you did.↩︎

  262. https://en.wikipedia.org/wiki/Unix_time↩︎

  263. The C spec doesn’t say exactly what time(NULL) will return, but the POSIX spec does! And virtually everyone returns exactly that: the number of seconds since epoch.↩︎

  264. https://en.wikipedia.org/wiki/Data_structure_alignment↩︎

  265. “Try to imagine all life as you know it stopping instantaneously and every molecule in your body exploding at the speed of light.” —Egon Spengler↩︎

  266. https://en.wikipedia.org/wiki/Core_dump↩︎

  267. quick_exit() differs from exit() in that open files might not be flushed and temporary files might not be removed.↩︎

  268. “In-place” meaning that the original array will hold the results; no new array is allocated.↩︎

  269. It always returns the number of bytes the transformed string took, but in this case because s1 was NULL, it doesn’t actually write a transformed string.↩︎

  270. Which you should because of spurious wakeups.↩︎

  271. Well, as at least as many things as you have free cores. Your OS will schedule them as it can.↩︎

  272. For example, if a destructor caused more variables to be set.↩︎

  273. Unix-like systems have a sleep() syscall that sleeps for an integer number of seconds. But thrd_sleep() is likely more portable and gives subsecond resolution, besides!↩︎

  274. When you say GMT, unless you’re talking specifically about the timezone and not the time, you probably mean “UTC”.↩︎

  275. The spec doesn’t actually say “clock ticks”, but I… am.↩︎

  276. Unless you’re on a POSIX system where time_t is definitely an integer, in which case you can subtract. But you should still use difftime() for maximum portability.↩︎

  277. https://man.archlinux.org/man/timegm.3.en↩︎

  278. https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/mkgmtime-mkgmtime32-mkgmtime64?view=msvc-160↩︎

  279. https://en.wikipedia.org/wiki/Unix_time↩︎

  280. https://en.wikipedia.org/wiki/ISO_week_date↩︎

  281. https://en.wikipedia.org/wiki/Symbols_for_Legacy_Computing↩︎

  282. https://stackoverflow.com/questions/17017331/c99-vscanf-for-dummies/17018046#17018046↩︎

  283. This is a variable, not a macro, so if you use it to define an array, it’ll be a variable-length array.↩︎

  284. In my non-scientific estimation. But for realsies, do the work before looking at the answer. It’s the best way to learn.↩︎

  285. https://beej.us/guide/bgc/source/exercises/intro/hello_name.c↩︎

  286. https://beej.us/guide/bgc/source/exercises/intro/hello_fruit.c↩︎

  287. https://beej.us/guide/bgc/source/exercises/varstat/pi_approx.c↩︎

  288. https://beej.us/guide/bgc/source/exercises/varstat/formula1.c↩︎

  289. https://beej.us/guide/bgc/source/exercises/varstat/formula2.c↩︎

  290. https://beej.us/guide/bgc/source/exercises/varstat/postinc.c↩︎

  291. https://beej.us/guide/bgc/source/exercises/varstat/predec.c↩︎

  292. https://beej.us/guide/bgc/source/exercises/varstat/foo17.c↩︎

  293. https://beej.us/guide/bgc/source/exercises/varstat/foo17b.c↩︎

  294. https://beej.us/guide/bgc/source/exercises/varstat/whilediv7.c↩︎

  295. https://beej.us/guide/bgc/source/exercises/varstat/twofor.c↩︎

  296. https://beej.us/guide/bgc/source/exercises/functions/funcxy.c↩︎

  297. https://beej.us/guide/bgc/source/exercises/functions/pi.c↩︎

  298. https://beej.us/guide/bgc/source/exercises/pointers/pointers.c↩︎

  299. https://beej.us/guide/bgc/source/exercises/pointers/swap.c↩︎

  300. https://beej.us/guide/bgc/source/exercises/arrays/sum.c↩︎

  301. https://beej.us/guide/bgc/source/exercises/arrays/init312.c↩︎

  302. https://en.wikipedia.org/wiki/Tic-tac-toe↩︎

  303. https://beej.us/guide/bgc/source/exercises/arrays/tictactoe.c↩︎

  304. https://beej.us/guide/bgc/source/exercises/strings/reverse.c↩︎

  305. https://beej.us/guide/bgc/source/exercises/strings/str_isupper.c↩︎

  306. https://beej.us/guide/bgc/source/exercises/strings/my_strchr.c↩︎

  307. https://beej.us/guide/bgc/source/exercises/structs/point.c↩︎

  308. https://beej.us/guide/bgc/source/exercises/structs/point_ptr.c↩︎

  309. https://beej.us/guide/bgc/source/exercises/io/reverselines.c↩︎

  310. https://beej.us/guide/bgc/source/exercises/io/input.txt↩︎

  311. https://beej.us/guide/bgc/source/exercises/io/point_avg.c↩︎

  312. https://beej.us/guide/bgc/source/exercises/typedef/vector3d.c↩︎

  313. https://beej.us/guide/bgc/source/exercises/pointers2/my_strchr.c↩︎

  314. https://beej.us/guide/bgc/source/exercises/pointers2/my_strrchr.c↩︎

  315. https://beej.us/guide/bgc/source/exercises/pointers2/object_sum.c↩︎

  316. https://beej.us/guide/bgc/source/exercises/pointers2/int_qsort.c↩︎