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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: How to Learn C in 2024?

4 点作者 gautamsomani12 个月前
I am an SRE who does bit of a coding, but now I want to pivot towards system programming. I know I should try Rust and may be even GoLang, but I very much believe I should also know good C, and by good I mean system-programming-level C.<p>I will follow this up with learning gcc a bit, valgrind, strace and gdb.<p>Any tips, recommendations?

4 条评论

0x020312 个月前
For the mechanics, there are a ton of good books, articles, and sites that can walk you through the syntax and I&#x27;m sure others here will have plenty of good suggestions on that.<p>While those are necessary, I&#x27;m of the opinion that you don&#x27;t really learn unless you do. For systems programming, there are many good projects out there for you to poke at. I&#x27;d suggest getting a hold of the source code for Linux, FreeBSD, and OpenBSD. Learn how to build each of them, and install&#x2F;run what you built to a VM. Then making a simple device driver for a serial or USB device would be a good introductory project. Even better, get an Arduino or something similar, and make&#x2F;program both ends. Maybe a little button&#x2F;light box that blinks if the CPU thermal throttles and can instruct the computer to launch an application when buttons are pressed for example.<p>At the end of the day, you&#x27;re just going to have to find something you&#x27;re interested in actually doing&#x2F;finishing so you can stay motivated enough to push your self up the learning curve, just like learning anything else really. The fact that you&#x27;ll be reading&#x2F;writing&#x2F;learning C is nearly irrelevant.
评论 #40509671 未加载
linguae12 个月前
My usual recommendation is to work through K&amp;R, which is how I learned C nearly 20 years ago as a high school senior taking an introductory C course at a community college. I still think this is a well-written book that will teach you the basics of C.<p>However, K&amp;R was last updated when the ANSI C standard was ratified, and there has been many important changes to C since then. Moreover, there are important safety concerns that need to be taken to account with coding in C, such as opting for functions like strlcpy for copying strings instead of the classic strcpy or the better-but-still-dangerous strncpy.<p>Once you are familiar with C, I then recommend learning some Unix system calls. I highly recommend looking at the source code of Unix utilities, and I also recommend textbooks such as <i>Advanced Programming in the Unix Environment</i> to learn more about Unix system calls.<p>When I was an undergrad at Cal Poly San Luis Obispo over 15 years ago, all computer science majors were required to take an intensive course on Unix systems programming in C. We built many projects, such as HTTP servers and shells. I highly recommend building projects like these to get very proficient in C.
gregjor12 个月前
K&amp;R still the best book on C. The language hasn&#x27;t changed all that much over the years.<p><i>The C Programming Language (Second Edition)</i> by Kernighan &amp; Ritchie. Available online for free:<p><a href="https:&#x2F;&#x2F;ia903407.us.archive.org&#x2F;35&#x2F;items&#x2F;the-ansi-c-programming-language-by-brian-w.-kernighan-dennis-m.-ritchie.org&#x2F;The%20ANSI%20C%20Programming%20Language%20by%20Brian%20W.%20Kernighan%2C%20Dennis%20M.%20Ritchie.pdf" rel="nofollow">https:&#x2F;&#x2F;ia903407.us.archive.org&#x2F;35&#x2F;items&#x2F;the-ansi-c-programm...</a><p>You can find other C books and online resources to get up to speed on &quot;modern&quot; C features (C99), but 95% of K&amp;R still applies.
richrichie12 个月前
Apart from the compulsory K&amp;R&#x27;s, I would also suggest Robert Seacord&#x27;s Effective C.