ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm reading the Advanced Programming in Unix Environment to do system level coding. I know one way to learn coding is to read other people's code first. I looked at a few open source projects (written in C) but they all seem pretty daunting; I don't even know where to begin. There's no main.c or anything like that. I don't understand 95% of the codes & find the whole process confusing. However, I have learned to use gcc, lint, gdb very well.
Any suggestions would be much appreciated. Thanks.
personally, i find reading a wad of code not very useful at all until you know what you are doing. Otherwise as you say it's a muddle.
Have you got Kernighan and Ritchie? http://en.wikipedia.org/wiki/The_C_P...anguage_(book)
The only way to learn is to do.
So i suggest you use the examples in your books
and fiddle about and experiment.
get used to using a debugger too so you can see what it all looks like. ddd is a very nice debugging tool which works on top of native debuggers.
Last edited by bigearsbilly; 05-16-2007 at 07:08 AM.
This may seem a strange qn but it's not clear from your qn; how much C have you done ie written ie time / lines of code?
Hi Chris
Over the years I have written approximately 1000 lines of C code. This includes basic hello world, structures, pointers, enums, #DEFINEs etc. etc. I have also learned how compilers work, gcc, ldd, linkers, gdb, make etc. along the way.
personally, i find reading a wad of code not very useful at all until you know what you are doing. Otherwise as you say it's a muddle.
Have you got Kernighan and Ritchie? http://en.wikipedia.org/wiki/The_C_P...anguage_(book)
The only way to learn is to do.
So i suggest you use the examples in your books
and fiddle about and experiment.
get used to using a debugger too so you can see what it all looks like. ddd is a very nice debugging tool which works on top of native debuggers.
Thanks. Yes. I bought K&R many moons ago and read bits and pieces from this book. I will definitely try to solve all the examples from this book and will also try out ddd.
well you must remember, any non trivial project has had probably hundreds and hundreds of
man hours spent on it. Even superman couldn't grasp it in one sitting now could he?
allegedly linux has 60 million lines of code.
at one line a minute to read that's 11 years solid reading.
it's like being annoyed because you could not build the golden gate bridge on your own
edit: oops 6 million, so thats only a year to read then!!!
Last edited by bigearsbilly; 05-16-2007 at 07:34 AM.
edit: oops 6 million, so thats only a year to read then!!!
Bargain, cheap at twice the price.
You could take a small Open Source project, get it running and then start changing small parts of it. Whilst that is really just an academic exercise it will help you more than just reading the code. By small I mean small, you've written 1000 loc, so try and find something of that size. Maybe a linux command like cat would be a good starting point, having no idea how big it is, I could be wrong but I bet it's easier than grep
Maybe a linux command like cat would be a good starting point, having no idea how big it is,
I tried going that route once. The problem is that all the coreutils share headers, functions and whatnot, so all the single command's code gets intermingled within. It is very frustrating to read, say, 'cat.c' and find it is fifteen lines long, and calls all its functional code from ~20 other files...
However, if you take the time to sort it out there is little doubt that it will educate you.
That said, I have personally rewritten a few of the coreutils from scratch in C as an educational exercise. So far I have uptime, free, cat, and rm.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.