tags:

views:

638

answers:

11
+9  Q: 

I need to learn C.

I'm a C# .NET developer.

I need to learn C for embedded systems. Quickly.

Where do I start?

+30  A: 

The K&R book is a good place to start.

Book Image

Link to Amazon

Being a C# developer and then learning C, I think its a great book. It's step by step with examples that are clear and are easy to understand. It may not get you everything you need to know for what you want to learn, but it definitely is an excellent start.

See senfo's comment below for the errata.

Kevin
I have a copy of this book from 1978 (also someone learning C). Would the 1978 version still be relevant?
tj111
That version would probably not be relevant because C89 is the most commonly used ANSI/ISO standard.
Billy ONeal
Loadmaster
It was definitely still relevant in 1998 when I learned C, at least. C doesn't change that much.
ptomato
Not to mention that ANSI/ISO standards conformance for embedded C toolsets is hit or miss, and the toolset will most likely come with a set of extensions. Read your toolset manuals carefully!
mocj
+1. Absolutely the best book I read when learning C. Also, be sure to check out the errata here: http://cm.bell-labs.com/cm/cs/cbook/2ediffs.html
senfo
ZJR
+5  A: 

There's no better way to learn than The C Programming Language by K&R. However, you might want to learn assembly as well, especially if you are targeting embedded systems.

Wedge
+13  A: 

two issues here

  • learning C
  • embedded systems

writing C for embedded systems can be quite different than writing C for systems.

for instance, if you are writing for something like the symbian, you write a style of C that is heavily influenced by the framework/operating system that doesn't look a lot like normal C code.

but, in general, get a book, use the internet.... find a forum specific to the embedded environment you will be using.

Keith Nicholas
A: 

Do some experiments on a PC before staring out with embedded systems c is far less strict then C#, it will let you do mistakes that will crush your application and corrupt the running environment without so much as a compiler warming. It will be good for you to do it in the interactive and familiar surrounding of the PC before tackling these problems in a limited embedded system.

Alon
+8  A: 

These are all online resources.Will definitely help you and save your time.

Specially for Embedded part :

These would suffice.

Ravi
+2  A: 

Since you'll probably be working with a small to non-existant library, you may also want to check out the book Algorithms in C by Robert Sedgewick.

BoltBait
This was the book used in my algorithms class, a while back, before 1997. It was good and I'm sure it's still applicable and in a new edition by now.
Bratch
+1  A: 

C isn't that hard, you have to first learn C syntax, then u have to move onto microcontrollers. there are many like PIC and AVR Atmel to name a few. good books for C are(as already mentioned above) without doubt the best book for beginners is The C Programming Language by K&R

for microcontroller are(basic books)

Joe Pardue - C Programming for Microcontroller

Programming 8 Bit Microcontroller In C

good luck

sazamsk
+2  A: 

I would suggest reverse engineering some code that you have already written. Ensure that the output is in C and you can see how ideas that you have implemented in C# translate to C. I have found this approach to be most effective in my learning.

If you need a tool I recommend Reflector.

Woot4Moo
+1  A: 

A little context would be useful - Do you expect to be writing a production quality app in 3 months, 6 months ? Are you prep-ing for an interview ? Are you writing a CGI module for your home web server ?

The bottom Line is it will take you 3 or 4 projects and 2 years before you are capable of writing a Commercial C app without supervision.

So if that is your situation, my advice is:

  • Test, plan to test, test to plan, and test some more. It will save your life.
  • Hire a C programmer, and assist him with the project.
  • Take a hands-on course ( you'll have to research those )
  • Be aware that Embedded is "special" in that it will require more knowledge of the platform, and more knowledge of the specifics of C Language behaviour, and may use non-standard libraries, and exclude standard libraries. As a result the quality of the documentation for the embedded environment will directly impact your success.
  • K&R is a fine reference, but a poor tutorial. This is an excellent book: http://publications.gbdirect.co.uk/c%5Fbook/
jdu.sg
2 years?? Someone can write an OS in that amount of time.
Ravi
In what language, Java ? Sure, you could write code for 2 years, make all the mistakes, throw it away, and write your OS for real after that. If you want to build software in C which can be reliably used outside of your garage/personal web site, then experience (or help) is a prerequisite. And in an embedded environment, there are more things to learn, and more obstacles to learning them. And don't forget that this is an estimate based on the info in a few-hundreds word post, and may not apply specifically to you.
jdu.sg
+1  A: 

Kernighan & Ritchie is obviously the obvious choice. For my money, the book that I end up reaching for when I've got a C question is "C: A Reference Manual" by Harbison & Steele, though.

bgporter
A: 

I have some work for you to do...

I would suggest getting the usual books (see the other answers) and possibly acquiring the C99 Standard.

But programming is something you have to actually do, so click here: code-golf. You want questions that have at least 10 upvotes. Solve the questions with the most upvotes first, as they will probably be the ones that have multiple possible and actual solutions.

At a Perl site, code-golf may just be about funny hacks. But here on Stack Overflow, people try out their new language skills, often posting completely uncompressed programs. See this SO answer and this SO answer for why, at least on Stack Overflow, code golf has more value than you might expect, and it certainly provides motivation to think hard...

Some of us, at least, will be watching!

DigitalRoss