4

Does anyone know any good resources with tasks or problems to get practice in things that are "new" in C from the point of view of someone with experience in high-level languages like C# and PHP? All I can seem to find are more "challenges" than problems for practice.

Thanks.

Alex S
  • 25,241
  • 18
  • 52
  • 63

9 Answers9

13

K & R. [Kernighan & Ritchie]

http://www.amazon.com/Programming-Language-Prentice-Hall-Software/dp/0131103628/ref=pd_bbs_1?ie=UTF8&s=books&qid=1240539543&sr=8-1

Dead account
  • 19,587
  • 13
  • 52
  • 82
Genericrich
  • 4,611
  • 5
  • 36
  • 55
  • Anyone know if there are any plans to produce a third edition? – dmckee --- ex-moderator kitten Apr 24 '09 at 02:33
  • 2
    @mmw: K&R may not be a good book for a first time programmer, but it is a wonderful volume for a capable programmer who is new to c. Or at least it was for me. – dmckee --- ex-moderator kitten Apr 24 '09 at 02:49
  • 2
    @mmw: The OP specifically asked for something that would be suitable for one is new to C, but who *already* has experience with high-level languages. – hbw Apr 24 '09 at 02:54
  • K&R is not only a wonderful volume for a capable programmer who is new to c, but also a fantastic reference book for a capable C-programmer. – AnnaR Apr 24 '09 at 07:10
  • 1
    IMHO, 1st edition K&R was a really well written book. It is slim, succinct, and clear. It explains the language itself well. It is not fluffy with redundant material, and does expect that the reader is paying attention. Later editions suffer some from the complexities introduced by the standards but are still remarkably readable. I'd agree about all editions of Stroustrup, however, with their unreadability increasing dramatically as the edition increases. – RBerteig Apr 24 '09 at 07:39
  • Full disclosure: I first learned C on a VAX 11/750 under VMS and Unix System 3 starting in 1982 from an early edition of K&R. I've used C on nearly every CPU I've touched since. – RBerteig Apr 24 '09 at 07:43
  • +1 Kernighan & Ritchie is a standard text. – Dead account Apr 24 '09 at 07:48
5

You could try Thinking in C by Bruce Eckel.

It is completely free of charge, and is available for download from his website.

Tian Bo
  • 551
  • 3
  • 7
  • 12
3

As others have said, read K&R.

Pay special attention to pointers, structs, unions, bit fields, typedefs, and the C preprocessor. Pointers and pointer arithmetic are very important.

Read the C preprocessor manual.

Learn to write makefiles. Read the manual for your version of make.

daotoad
  • 26,689
  • 7
  • 59
  • 100
  • 1
    +1 Makefiles are essential. Autotools are also a great idea, but almost more trouble than they're worth if you have no plans to distribute you work widely. – Chris Lutz Apr 24 '09 at 07:23
1

K&R is outdated.

I prefer C Primer Plus 5th Ed by Stephen Prata ISBN: 0-672-32696-5

It covers C99.

Hideo
  • 387
  • 3
  • 4
  • GCC has good C99 support, but it's not complete, and few other compilers even try for C99. Also, a lot of people will use a C++ compiler, and then what is C99 support worth? I generally code in C89 for assured portability. It's better (in my humble opinion) to learn C as C89, and when you know that find all the cool new goodies in C99 because, despite having been made 10 years ago, they still feel cool and new (and are still not all implemented). – Chris Lutz Apr 24 '09 at 07:37
  • I don't use C++. I use solely C, so it matters to me. ;) I also use assembly language. – Hideo Apr 24 '09 at 09:49
0

This supposed to be C bible.

J.W.
  • 17,991
  • 7
  • 43
  • 76
0

Problem Solving and Program Design in C

by

Jeri R. Hanly, Elliot B. Koffmon and Frank L. Friedman

Dan Adams
  • 124
  • 2
  • 9
0

Check out The Standard C Library by P. J. Plauger, from 1991. It alternates quotes from the standard (C89, I believe) with discussion of how the library functions were intended to be used, along with a fully described implementation of the complete C standard library. Source code is included as well.

Yes, the book hasn't been updated for the latest standard, but it still has a lot of value from explaining at least some of the rationale behind some of the oddities of the standard library. Incidentally, Plauger was on the standards committee.

Plauger wrote a number of the classic books on both C and early Unix. Track down and read the oldest for a taste of pre-C history...

RBerteig
  • 41,948
  • 7
  • 88
  • 128
0

Given your previous (C#) programming experience I guess you don't need a book that teaches how to program but the intricacies and subtleties of C. I'd recommend the following:

  • Prentice Hall - The ANSI C Programming Language 2nd ed. by Brian W. Kernighan and Dennis M. Ritchie. For basic questions.
  • Prentice Hall - Expert C Programming. Deep C Secrets.
  • ISO - C 99 Standard - final. Very useful for many doubts and questions
piotr
  • 5,657
  • 1
  • 35
  • 60
0

A source of problems to solve that have known answers is Project Euler.

It isn't itself C specific since there is a decidedly mathematical orientation to the problems as presented. However, making an honest attempt to solve a significant number of them would require a growing proficiency with structures, pointers, the standard library, and thinking about things in ways that work well in C.

Another resource that often seems to be overlooked is that MIT has been putting a large percentage of their curriculum online. Their EE/CS department is no exception. The class Introduction to Algorithms might be one suitable choice. The textbook is Introduction to Algorithms, Second Edition, by Cormen, Leiserson, Rivest, and Stein which is reasonably well written as text books go. I didn't exhaustively search the course list, so I'm sure there are other gems in there as well.

RBerteig
  • 41,948
  • 7
  • 88
  • 128