the flattening
not to be confused with the Minecraft technical update I'm moving about the pages to be have a more flat, less nested structure. I feel like that'll improve URLs a lot, making them more readable than ever. over the years I've learned that flatter is better, and that tagging is generally a much more effective way of organising things. this doesn't get rid of categories entirely, as I think having the category makes the URL much a bit more readable in the end. my current vision does include a concept of "major categories" either way.
This commit is contained in:
parent
20e29e3b2c
commit
39a6155bdc
33 changed files with 63 additions and 120 deletions
17
content/programming/cstring-starts-with.tree
Normal file
17
content/programming/cstring-starts-with.tree
Normal file
|
@ -0,0 +1,17 @@
|
|||
%% title = "prefix matches with C strings"
|
||||
|
||||
% id = "01JCGAM55352EF247HZ358BAJ8"
|
||||
- one thing I realised while reading some code at work that worked with C strings: it's surprising how easy it is to match a prefix on a C string.
|
||||
|
||||
```c
|
||||
if (s != NULL
|
||||
&& s[0] == 'h'
|
||||
&& s[1] == 'u'
|
||||
&& s[2] == 'g')
|
||||
{
|
||||
// ...
|
||||
}
|
||||
```
|
||||
|
||||
% id = "01JCGAM5537WYE3GEN6WGX8WD0"
|
||||
- this works because of the NUL terminator---if it appears at any point in the string, the `s[i] == c` comparison will return `false`, thus breaking the `&&` chain---so indices always stay in-bounds!
|
Loading…
Add table
Add a link
Reference in a new issue