TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Essential C (2003) [pdf]

183 点作者 th33ngineer超过 4 年前

17 条评论

callinyouin超过 4 年前
This, paired with their Pointers and Memory [1] guide are how I learned C in college. They&#x27;re both pretty short and to the point, I would highly recommend.<p>[1] <a href="http:&#x2F;&#x2F;cslibrary.stanford.edu&#x2F;102&#x2F;PointersAndMemory.pdf" rel="nofollow">http:&#x2F;&#x2F;cslibrary.stanford.edu&#x2F;102&#x2F;PointersAndMemory.pdf</a>
评论 #24356822 未加载
underanalyzer超过 4 年前
<i>Now then, isn&#x27;t that nicer? (editorial) Build programs that do something cool rather than programs which flex the language&#x27;s syntax. Syntax -- who cares?</i><p>Although some feel like it’s too opinionated to belong in this article I really appreciated the above. <i>Edit</i> To be clear the author is advocating for simpler syntax here to increase program readability. This could be taken other ways.
commandlinefan超过 4 年前
&gt; Relying on the difference between the pre and post variations of these operators is a classic area of C programmer ego showmanship.<p>Ugh. He&#x27;s talking about inline use of post-increment and pre-increment (i.e. x++ and ++x) here. This is perfectly readable to a C programmer, and sidestepping them actually makes the code harder to understand.
评论 #24357105 未加载
hivacruz超过 4 年前
I highly recommend the CS50 course to get familiar with C:<p><a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;playlist?list=PLhQjrBD2T381L3iZyDTxRwOBuUt6m1FnW" rel="nofollow">https:&#x2F;&#x2F;www.youtube.com&#x2F;playlist?list=PLhQjrBD2T381L3iZyDTxR...</a><p>Sure it doesn&#x27;t get in details about the language but you get the essential and the videos are great.
评论 #24359352 未加载
评论 #24358214 未加载
eternalban超过 4 年前
There is also Jens Gustedt&#x27;s <i>Modern C</i>:<p><a href="https:&#x2F;&#x2F;modernc.gforge.inria.fr&#x2F;#org81433c2" rel="nofollow">https:&#x2F;&#x2F;modernc.gforge.inria.fr&#x2F;#org81433c2</a>
stellersjay超过 4 年前
I prefer something that is more up to date <a href="https:&#x2F;&#x2F;nostarch.com&#x2F;Effective_C" rel="nofollow">https:&#x2F;&#x2F;nostarch.com&#x2F;Effective_C</a>
heinrichhartman超过 4 年前
While we are here, does anyone have a good resource about memory management strategies in C?<p>Topics:<p>* Best practices for C function signatures (caller allocates (which size?), callee allocates (where? which allocator?))<p>* Memory Ownership Models<p>* Borrowing<p>* Reference Counting<p>* Garbage Collectors and C-Libraries providing this functionality<p>* Interning Objects (Strings)<p>* RAII [1]? And it&#x27;s benefits&#x2F;flaws<p>[1] <a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Resource_acquisition_is_initialization" rel="nofollow">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Resource_acquisition_is_initia...</a><p>Context: I feel that understanding the C memory primitives in not that hard (stack variables, malloc&#x2F;free, C++&#x27;s new). But how to use them is devilishly tricky. I have seen little information about this.
评论 #24362269 未加载
marttt超过 4 年前
&quot;Teach Yourself C in 24 Hours&quot; by Tony Zhang (1997) seems interesting as well:<p><a href="http:&#x2F;&#x2F;aelinik.free.fr&#x2F;c&#x2F;" rel="nofollow">http:&#x2F;&#x2F;aelinik.free.fr&#x2F;c&#x2F;</a><p>A previous HN discussion on that book:<p><a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15624521" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=15624521</a><p>EDIT: That earlier discussion has an excellent first post. Quoting:<p>&quot;It bothers me so much that very few books (Kernighan) talk about WHY. WHY. WHY is a variable needed? WHY is a function needed? WHY do we use OOP? Every single book out there jumps straight into explaining objects, how to create them, constructors, blah blah blah. No one fricking talks about what&#x27;s the point of all this?<p>Teaching syntax is like muscle memory for learning Guitar. It is trivial and simply takes time. Syntax - everyone can learn and it is only one part of learning how to code. Concepts are explained on their own without building upon it.<p>[... A list with learning resources the poster finds great ...]<p>This is learning how to produce music. Not learning the F chord. Teaching how to code is fundamentally broken and very few books&#x2F;courses do it well.&quot;
johnnujler超过 4 年前
&gt; <i>Now then, isn&#x27;t that nicer? (editorial) Build programs that do something cool rather than programs which flex the language&#x27;s syntax. Syntax -- who cares?</i><p>I never really got to a point of learning Haskell or Lisp up until recently, it was always this --- I can do everything with C&#x2F;C++&#x2F;Java&#x2F;Python and <i>I could</i>. But the thing is it is only after learning lisp that I really got the hang of thinking in top down manner(recursively), or for that matter it took Haskell to teach me composition intuitively, which then could be extended to my main language(C++). I understand that syntax doesn&#x27;t matter much, but fwiw I still think in terms of lisp syntax when writing recursive code in C++&#x2F;C. So yeah, take that for you will.
saagarjha超过 4 年前
This guide is short (which is always nice) but not has a couple of flaws in places in the brief skim I gave it. For example:<p>&gt; In particular, if you are designing a function that will be implemented on several different machines, it is a good idea to use typedefs to set up types like Int32 for 32 bit int and Int16 for 16 bit int.<p>Use &lt;stdint.h&gt; please<p>&gt; The char constant &#x27;A&#x27; is really just a synonym for the ordinary integer value 65 which is the ASCII value<p>Not always, especially right after you came off a paragraph explaining how different machines have implementation-specific behaviors<p>&gt; The compiler can do whatever it wants in overflow situations -- typically the high order bits just vanish.<p>This is a good time to explain what undefined behavior actually means<p>&gt; The &#x2F;&#x2F; comment form is so handy that many C compilers now also support it, although it is not technically part of the C language.<p>Part of the language since C99<p>&gt; C does not have a distinct boolean type<p>_Bool since C99<p>&gt; Relying on the difference between the pre and post variations of these operators is a classic area of C programmer ego showmanship.<p>I&#x27;m fine with you mentioning that this can be tricky, but this is more opinion than I am comfortable with in an introductory text<p>&gt; The value 0 is false, anything else is true. The operators evaluate left to right and stop as soon as the truth or falsity of the expression can be deduced. (Such operators are called &quot;short circuiting&quot;) In ANSI C, these are furthermore guaranteed to use 1 to represent true, and not just some random non-zero bit pattern.<p>Under the assumption that there are no boolean types from earlier, this is not true<p>&gt; The do-while is an unpopular area of the language, most everyone tries to use the straight while if at all possible.<p>I would argue that people use do-while more than they need to<p>&gt; I generally stick the * on the left with the type.<p>Not a problem, but :(<p>&gt; The &amp; operator is one of the ways that pointers are set to point to things. The &amp; operator computes a pointer to the argument to its right. The argument can be any variable which takes up space in the stack or heap<p>And constants&#x2F;globals<p>&gt; To avoid buffer overflow attacks, production code should check the size of the data first, to make sure it fits in the destination string. See the strlcpy() function in Appendix A.<p>strlcpy is non-standard and probably not what you want<p>&gt; The programmer is allowed to cast any pointer type to any other pointer type like this to change the code the compiler generates.<p>&gt; p = (int * ) ( ((char * )p) + 12); &#x2F;&#x2F; [Some spaces added by me to prevent Hacker News from eating the formatting]<p>Only in some very specific cases…<p>&gt; Because the block pointer returned by malloc() is a void* (i.e. it makes no claim about the type of its pointee), a cast will probably be required when storing the void* pointer into a regular typed pointer.<p>Casting malloc is never required (and I would say usually not a good thing to do)
评论 #24359270 未加载
评论 #24363598 未加载
评论 #24361977 未加载
评论 #24359268 未加载
dang超过 4 年前
If curious see also<p>2018 <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=18790421" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=18790421</a><p>2016 <a href="https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11671985" rel="nofollow">https:&#x2F;&#x2F;news.ycombinator.com&#x2F;item?id=11671985</a>
ngcc_hk超过 4 年前
Normal c is not difficult. But once get yourselves into using it in eg the hacking of game boy (still remember the confusion of the data, tile etc) and basic bare metal small machine. Just hard.
andrewstuart超过 4 年前
I don&#x27;t want to learn C but certain types of applications there&#x27;s really no practical alternative.
评论 #24359434 未加载
orionblastar超过 4 年前
I learned from Sam&#x27;s C Primer Plus.<p><a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;Primer-Plus-5th-Stephen-Prata&#x2F;dp&#x2F;0672326965" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;Primer-Plus-5th-Stephen-Prata&#x2F;dp&#x2F;0672...</a><p>My version was older than the Amazon version as I learned in 1987.
hacktember超过 4 年前
This was the PDF used in my UNIX class! That brings back some memories...
Flex247A超过 4 年前
A very great resource!
评论 #24361404 未加载
jimbob45超过 4 年前
This is a pretty neat guide if you’re cheap and have moral qualms about pirating K&amp;R. Still, I think the best introduction to C remains K&amp;R.
评论 #24358322 未加载