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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Where to begin when learning C? Start by making lots of errors

68 点作者 morganwilde超过 11 年前

16 条评论

tptacek超过 11 年前
This situation is why there is &quot;hello world&quot;; that program seems trivial but actually has important implications; for instance, that your environment works, that you know how to feed programs to the compiler, that you can actually run the output.<p>I never took &quot;hello world&quot; seriously until I started doing embedded systems work; it&#x27;s now an extraordinarily important tool for me (I work an anomalously weird number of different environments).
评论 #6745091 未加载
评论 #6746579 未加载
评论 #6746738 未加载
kabdib超过 11 年前
I learned C by reading K and R and doing the book&#x27;s exercises . . . on paper. At the time I didn&#x27;t have access to a C compiler, so I wrote them all out in a notebook. A month later I got a job at a shop that was running Unix, and got the chance to type my programs in and try them.<p>I had a lot of things wrong. It took me a while to understand the difference between control-D and EOF, for instance (how embarrassing). But the 30 days I spent without a compiler made me <i>think</i> about program behavior.<p>I&#x27;m not saying this is a great way to learn a language, but it can be done.<p>I keep hearing people complain about K and R being &quot;a terrible book.&quot; For me it was perfect: pragmatic, succinct, with great examples and good exercises.
评论 #6744837 未加载
评论 #6745201 未加载
评论 #6746001 未加载
评论 #6745129 未加载
评论 #6744836 未加载
评论 #6744813 未加载
pjmlp超过 11 年前
By making sure to <i>enable all warnings</i>, <i>enable warnings as errors</i> and use a compiler that integrates static analysis like clang.
评论 #6744759 未加载
评论 #6744926 未加载
评论 #6744755 未加载
评论 #6745084 未加载
foster1890超过 11 年前
Where to begin when learning C? Start at <a href="http://c.learncodethehardway.org/" rel="nofollow">http:&#x2F;&#x2F;c.learncodethehardway.org&#x2F;</a>. It&#x27;s going to be tough to top Zed Shaw&#x27;s approach. The best way to learn code is by writing code.
评论 #6746735 未加载
评论 #6746187 未加载
yetanotherphd超过 11 年前
I think I have some ingrained fear of making errors, from the days where a simple error might cause your program to chew through your whole hard drive. Actually I don&#x27;t know if that was ever the case, but that&#x27;s how I felt.<p>Anyway, the hardest step for me in learning a language is when I take some running code and make one change to see what happens. Once I get in the swing of it, it gets much easier, but that first step is still hard to do.
vparikh超过 11 年前
In order to for people to really understand C and be proficient in it very clearly, I always recommend that they learn the basics of programming (memory, basic types, looping structures and array manipulation) in a simple assembly language such as 6502. This helps immensely with understanding pointers and deciphering the many cryptic C compiler messages.
b0rsuk超过 11 年前
Install Valgrind. It makes error messages a lot less cryptic (my #1 problem with C... not that&#x27;s it&#x27;s limited to C). If you don&#x27;t get proper feedback, it&#x27;s not learning, just banging your head against the wall.
评论 #6746297 未加载
评论 #6746093 未加载
idoescompooters超过 11 年前
Currently, I&#x27;m learning Python and have been learning it for over a year now. I&#x27;ve been thinking about moving to C as my next language. Is this a good idea? I&#x27;m eventually going to want to learn C++, but I&#x27;m not going to learn Java until I have to. Also, what are some really good C learning resources? I know there&#x27;s K&amp;R and learncthehardway.org
eonil超过 11 年前
I thinks this is a good approach. Checking most of possible exceptional cases while following regular learning course.<p>Errors = safety nets are usually the main reason to make stiff learning curve. This would be a great help for them.
agumonkey超过 11 年前
As other people said earlier, reading existing code is great, when you have good sources. I&#x27;m an almost noob in C, and currently reading Ian Piumarta sources[1], I find they&#x27;re superb in presentation and design.<p><a href="http://piumarta.com/software/" rel="nofollow">http:&#x2F;&#x2F;piumarta.com&#x2F;software&#x2F;</a><p>[1] mostly for maru, his lisp system, but even tty2html (ascii control -&gt; html) is very clean and elegant.
mtdewcmu超过 11 年前
A minor point, but important to understand: the error came from the linker, not the compiler. It compiled just fine.
评论 #6746672 未加载
morganwilde超过 11 年前
By the way, I would love any feedback on this approach and where I should take this further.
评论 #6745437 未加载
评论 #6745239 未加载
评论 #6746732 未加载
laveur超过 11 年前
This all of this!
lhgaghl超过 11 年前
This is stupid. You should learn C properly (know how to avoid undefined behavior) or not at all. Exception if you&#x27;re doing something that can tolerate remote code execution.
passfree超过 11 年前
You should learn go instead of C.
评论 #6746231 未加载
mbq超过 11 年前
Actually the message quoted complains about the lack of _main not main, so the rest of this post is a huge overinterpretation. _main is IMO some windoizm connected to the use of WinMain for GUI apps.
评论 #6745232 未加载
评论 #6745208 未加载