Essential C (2003) [pdf]
cslibrary.stanford.edu
cslibrary.stanford.edu
For those who already know the syntax of C but wanted to learn more, the links I mentioned is a good exercise and opens up a lot of possibilities on what you can implement. You'll soon be able to realize the importance of linked list and why you'll want to use a linked list instead of just plain arrays.
[0] - http://cslibrary.stanford.edu/103/LinkedListBasics.pdf
[1] - http://cslibrary.stanford.edu/105/LinkedListProblems.pdf
https://github.com/torvalds/linux/search?utf8=%E2%9C%93&q=IN...
That's unbearable. They should just redo this in JavaScript. That's what everyone uses nowadays. Or so they say on here, if I understand correctly.
Cache, as opposed to 20+ years ago, or whenever the pattern was developed, is indeed a thing that everyone is using just now.
The best data structure or algorithm to use is usually problem-dependent.
> ... why you'll want to use a linked list instead of just plain arrays
If your problem requires a lot of list processing, use a language more suitable for it. Otherwise, use extensible arrays, which are easy to implement in C.
conceit also pointed out that lists also increase the likelihood of cache misses, which slows down the program a little bit. Many C programmers care about that. I don't share their priorities - it is important to me, but less so than correctness, ease of programming (allowing more time for exploration and finding a more efficient algorithm), and response times.
Just allocate all the list items from a big pool of memory that you own. When you're done, throw the whole lot away in one go. Languages like C++ tend to encourage micromanagement of data but it's not the only way to do things.
Here's a proper reference on C99 and C11:
http://en.cppreference.com/w/c
And see also reallocarray.
It's far from perfect but still a useful tool.
It's a choice they made to make it easy to detect truncation. If you don't care about the return value of strlcpy you can modify it to skip that part (which IMO will make it worse) but get rid of traversing src until \0 is found.
If you know you're working with non-terminated "strings" then just use memcpy instead.
If you're using proper functions you shouldn't end up with a non NUL-terminated string in the first place, although there are shortcomings in the commonly used libraries here unfortunately yes. It's hard to create a function that solves all problems.
(Side note: IMO The return value of latest OpenBSD version of strlcat (cat not cpy) is a bit weird when size is smaller than strlen(dst))
> Build programs that do something cool rather than programs which flex the language's syntax. Syntax -- who cares?
Otherwise, I'd never heard of/seen the `#pragma once` preprocessor directive. (Not that I do that much C programming!) How common is it to use this over include guards?
Not very. It works in Microsoft's C compiler but can't be relied on elsewhere.
Pronounced 'car'? Bollocks. Pronounced char as in charred.
It's /kɛər/, as you can see here: https://en.wikipedia.org/wiki/Help:IPA_for_English
And, for the record, I have the Mary-marry-merry merger: https://en.wikipedia.org/wiki/English-language_vowel_changes...
It's as noob as when someone pronounces nginx [njinkx] instead of [engin-x], or linux as [li-nux] instead of [lin-ux].
C Infrequently Asked Questions #19.26, https://www.seebs.net/faqs/c-iaq.html
I later noticed some people do pronounce it "car" which just seems odd. Why change it, if it doesn't save a syllable? It's not a truncation of how "character" is said either, because that's a different vowel sound.
Saying 'car' causes problems when learning C++, because all OOP examples on composition start "Car has-an Engine".
I remember reading the "care as in character" thing years ago and just boggling at it -- who on earth makes character start with care? (As a British person, I think the first syllable of character rhymes with cat. There isn't a word that sounds like that but ending in r.) So rather than settle the question for me, it just dug the hole deeper.
Listening to Kernighan, I can just about hear what that remark meant.
(I say char myself, like the fish)
I've always pronounced "char" as "car". Dunno why, I learned C from a book, so no one got to tell me I was wrong.
Not that I say it that way, I've always heard and said var-char
char grinned;
char *var = "varchar";I don't think there's a consensus between car/char/care, though, even among C's creators. But if there was, I would vote for 'care'.
I always thought SQL was another weird one. When discussing the language itself, you can say 'sequel' or 'ess queue ell' interchangeably, but when referring to a database that has "SQL" in its name, there is a DB-specific one true pronunciation:
* SQL Server: 'sequel server'
* PostgreSQL: 'post gress queue ell'
* SQLite: 'sequel light'
* MySQL: 'my ess queue ell'
There's no complete consensus on any of those- just a preponderance of one, or an officially endorsed pronunciation in a FAQ someplace.
I've also heard 'my squeal' for MySQL, breaking out of the 'sequel'/'ess queue ell' duopoly altogether.
Except the first syllable of 'character' is neither 'car' nor 'care', unless you have a really weird accent or are intentionally making fun of the English upper class.
PS: I always liked "squirrel" for SQL but sadly that one never got much traction.
Conversations like this are hard because accent doesn't transmit through text. I'm Irish.
The "listen" button here pronounces the words with an American accent:
I think that feature must be localised -- here it gives me a (female) voice with an English accent, and the two words sound quite different.
It does if you use IPA.
The only way I could pronounce it 'care' is if I were from the southern hemisphere.
However, in most American dialects, marry-merry-Mary are all merged and pronounced identically (IPA: /mɛɹi/, though the exact vowel isn't important here, and all three vowels generally sound the same to merged speakers). Furthermore, the first syllable of all these words is usually pronounced the same as the vowel in mare (/mɛɹ/).
So let's put this together. The word "care" is pronounced /kɛr/ in both merged and unmerged dialects (or /kɛː/ if you don't pronounce the /r/ there). In unmerged dialects, the word "character" is pronounced /kærəktər/, so it doesn't make sense that you'd truncate it to /kær/, because /ær/ (or /æː/) at the end of a syllable doesn't occur in any English dialect[2]. In merged dialects, however, "character" is pronounced /kɛrəktər/, so it makes sense to truncate it to /kɛr/, which is a homophone of "care".
[1]: https://en.wikipedia.org/wiki/English-language_vowel_changes...
[2]: Except Irish English, see https://news.ycombinator.com/item?id=11673067.
[3]: I speak a merged dialect, and pronounce "char" as /kɛr/ when I'm reading C code.
This "'foo' as in 'bar'" stuff is worse than useless most of the time, as you've just been shown.
Plenty of people understand IPA.
> No, "car as in character" is still.
It's still completely incomprehensible unless you know which vowel sound is meant, which is the whole point of this sub-thread.
"Plenty of people" is misleading. Plenty as in thousands, millions of people worldwide, possibly, not not plenty as a percentage of the english people world. I'd be surprised if more than 5% of english speakers look at an IPA description of a sound and do anything other than go "what the fuck does that mean?".
> char: /keir/, /char/, /kar/, n.
But as of 2003, support for C99 wasn't very widespread, so omitting <stdint.h> was understandable.
I'd love to see an updated version.