5 ms·
https://www.learn-c.org/ https://www.learn-c.org/ If you have lots of time: https://hal.inria.fr/hal-02383654 https://hal.inria.fr/hal-02383654 If you can't b
by suprjami 4y ago
https://www.learn-c.org/ https://www.learn-c.org/
If you have lots of time: https://hal.inria.fr/hal-02383654 https://hal.inria.fr/hal-02383654
If you can't be bothered reading a whole book: https://matt.sh/howto-c https://matt.sh/howto-c
Exercises: https://www.codestepbystep.com/problem/list/c https://www.codestepbystep.com/problem/list/c and https://exercism.org/tracks/c https://exercism.org/tracks/c
Once you have syntax and basic algorithms down well, watch this, the only 2 hour YouTube video I'll ever recommend: https://m.youtube.com/watch?v=443UNeGrFoM https://m.youtube.com/watch?v=443UNeGrFoM
Both r/cprogramming and r/C_programming are active, also full of lazy students trying to get people to do their homework. If you come by, describe your problem well with code. Say you're learning for yourself, not for school.
Together C & C++ is a good Discord if you prefer live chat: https://discord.gg/tccpp https://discord.gg/tccpp
- mattpallissard 4y ago#c on libera is a genuinely helpful place full of neckbeards.
- bogomipz 4y agoSorry if this is silly question but what is libera?
- flippant 4y agoIt's an IRC network. https://libera.chat/ https://libera.chat/
- cinntaile 4y agoA sibling comment already mentioned what it is so I'll not repeat that. Just some additional context if you're somewhat familiar with IRC. It's the spiritual successor of Freenode after it was taken over by a member of that community.
- queuebert 4y ago#c-jeopardy is great fun as well.
- galangalalgol 4y agoAny recommendations on static analyzers, unit tests, coverage for c? Can clang tidy give hints about modern c they way it does about modern c++?
- cillian64 4y agoOne useful tool is running clang or gcc with —Werror -Wpedantic which will point out a lot of things which are useful to know about, even if occasionally a false positive.
- flohofwoe 4y agoSet warning level to max, use clang static analyzer or clang tidy (I'm not quite sure how those two relate to each other though), and especially ASAN (Address Sanitizer) and UBSAN (Undefined Behaviour Sanitizer) (and if you write threaded code: TSAN (ThreadSanitizer). One thing that Apple did right in Xcode and where other IDEs lagged behind is easy access to those tools from the UI.
- galangalalgol 4y agoThat sounds like all the things I do for c++. One thing I really like is that clang tidy can flag the "old way" to do stuff. Was hoping it had that for c.
- gregfjohnson 4y agoNot exactly your question, but valgrind is an amazing tool. It does execution-time analysis of your code and provides an in-depth report on memory usage. It will find and report memory leaks, use of uninitialized variables, bad memory references, etc. I love programming in C, but there are a lot of ways to corrupt memory, get segfaults, etc. valgrind is a useful and powerful way to guard against many of these kinds of problems. C++ is no better. The way I see it, programming in C is like lying on a bed of nails. Doable if you are very careful. With C++, they put a sheet over the bed of nails.
- galangalalgol 4y ago
- mozball 4y agoWhat is your opinion on K&R?
- fn-mote 4y agoIt's great for what it is, but the language and style have come a long way since then. It would be better to learn "Modern C" (this is the title of a book but also at least learn C99 not K&R C). E.g., people like the book by Jens Gustedt. I'm ambivalent about it, but it sure machine-guns the important points. [1] https://hal.inria.fr/hal-02383654/file/ModernC.pdf https://hal.inria.fr/hal-02383654/file/ModernC.pdf
- Koshkin 4y ago> not K&R C K&R the 2nd edition of book teaches ANSI C. (It is still the best intro into the basics of C.)
- flohofwoe 4y agoIt's much too awkward IMHO, C99 and onward almost feels like a whole new language (mainly because of struct literal and designated init support).
- rightbyte 4y agoNot being forced to declare symbols in the beginning of the scope is the real game changer I say. K&R or C89 without e.g. GNU extensions is really annoying to use.
- bluecalm 4y agoIdk about that. I think it's code with everything declared at the beginning of the scope is easier to read and understand. Every time I see code written in this style (Git, Linux) it's easier to build a mental model of what is happening.
- stusmall 4y agoNot the person you are replying to, but here are my thoughts. It sounds like OP is looking to learn C for historical and contextual reasons, and for that K&R is perfect. The history of C is very K&R-centric. For modern, practical C programing it is missing a lot though. It is a short, simple, from the original authors introduction to the language itself. There is nothing about how to test your code, how to set it up for long term maintainability, how to mitigate some of the security downfalls or even any of the features added since C89. It's a good technical book. A great one for it's time and subject matter. But that caveat is important, it needs to be taken in context of the time. It shouldn't be the first, and absolutely not the only, book you read if you are writing modern production C in 2023.
- voidhorse 4y ago+1 to https://hal.inria.fr/hal-02383654 https://hal.inria.fr/hal-02383654. It covers the language in extreme depth, and you likely won't remember it all on a first read but you'll walk away with a pretty good general understanding of the language. Plus, the author is an active contributor to the language. I love C. As dangerous and as tedious it can be for large projects, I think it's my top choice for solo endeavors that don't require too many string manipulations. I don't think any language has come close to achieving the same balance of elegance and simplicity--maybe scheme? (zig comes close but has a substantial number of features that move it away from simplicity (e.g. payload capture))
- MonkeyClub 4y ago> Once you have syntax and basic algorithms down well, watch this, the only 2 hour YouTube video I'll ever recommend: > https://m.youtube.com/watch?v=443UNeGrFoM https://m.youtube.com/watch?v=443UNeGrFoM Hard +1 on this! I think Eskil Steenberg work in C is really top notch - the video is heavily recommended, as is an overview of his work in general, he does some awesome stuff with C.
- flohofwoe 4y agoFrom the learn-c link: /* draws a point at 10, 5 */ struct point p; p.x = 10; p.y = 5; draw(p); I wish that would be a bit more 'modern', for instance: struct point p = { .x = 10, .y = 5 }; draw(p); ...or even: draw((struct point){ .x = 10, .y = 5 }); ...main reason being that this avoids any accidents with unitialized data if the struct grows (the compound literal initialization makes sure that any struct members that are not mentioned are set to zero, while with the 'old school' approach you might end up with random junk in the struct).
- suprjami 4y agoI also love designated initialisers. C99 ftw.