Mailing List Archive
tlug.jp Mailing List tlug archive tlug Mailing List Archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]Re: [tlug] good C book for iso c99?
- Date: Tue, 23 Oct 2007 11:32:43 +0200
- From: Attila Kinali <attila@example.com>
- Subject: Re: [tlug] good C book for iso c99?
- References: <ff055fb80710222217l7b490725ta999251879e56c36@mail.gmail.com>
- Organization: SEELE
On Tue, 23 Oct 2007 14:17:47 +0900 "Miles Colman" <mcolman@example.com> wrote: > anyone know of a good reference/learning book that includes features of iso > c99? I keep hearing about K&R but it's ooooold. K&R is IMHO one of the best books around to learn C, although it is definitly in need of an update. I also often recomend Prata's "C++ Primer Plus", which has an IMHO excelent introduction in to programming with a C-based language. If you just read up to the point where classes are introduced, you'll get a good overview of how to write C with a reasonable style. (Side note: C++ is, contrary to the common opinion, not a superset of C. There are various little differences. But fortunately, they don't matter until you get to a more advanced level of programming) Other than those two books, i can only recommend to read the C99 standard itself which is freely available on the net. If you know how to write C and only have to look up exact definitions, then this is a viable way to go. > Context, if you want to know: > I'm just learning C, and my book has been teaching me stuff like: > my_struct_ptr = (int* ) malloc( sizeof( my_struct) ); > my C book (c. 1994, On to C by Patrick Winston) says you should always make > casts like this, or the type will be undefined. C curricula on the web of a > similar vintage say the same thing (cf. eg > http://www-ee.eng.hawaii.edu/~tep/EE150/book/chap14/subsection2.1.2.1.html ) > However, wikipedia has more recent info, which explains why the cast is no > longer necessary: > http://faq.cprogramming.com/cgi-bin/smartfaq.cgi?id=1043284351&answer=1047673478 Uhmm.. to cast or not to cast, this is the question. There are two groups of people out there, one who say that there should be always a cast and those who say you should never cast unless really necessary. There are various arguments for each side, but none of them are really convincing. I normaly go the way inbetween those extremes. I cast whenever the compiler complains about a missing cast or when it might be ambigous, but generally let the compiler figure out what to cast when. Also a good way is to lurk on the developer mailinglists of OSS projects that are performance critical. There often discussions about the right style of C to tell the compiler how to do something the way the programmer intents arise. Oh, btw: be aware that gcc has lots of bugs. Thus if you ever hit a strange problem, have a look at the assembler output of gcc and check whether it has done the right thing. Attila Kinali -- Praised are the Fountains of Shelieth, the silver harp of the waters, But blest in my name forever this stream that stanched my thirst! -- Deed of Morred
- References:
- [tlug] good C book for iso c99?
- From: Miles Colman
Home | Main Index | Thread Index
- Prev by Date: Re: [tlug] good C book for iso c99?
- Next by Date: Re: [tlug] good C book for iso c99?
- Previous by thread: Re: [tlug] good C book for iso c99?
- Next by thread: Re: [tlug] good C book for iso c99?
- Index(es):
Home Page Mailing List Linux and Japan TLUG Members Links