Reputation: 11595
I am relatively proficient in Objective-C but I have been looking around some frameworks and libraries I might use in the future and I am increasingly seeing the use of C. So far the only applications I have written contain only Objective-C. I know Objective-C is a superset of C, but what I mean when I say that I have only written in Objective-C is that I have only used Objective-C methods and the syntax of Objective-C that is distinctly different from C syntax. I've been going through questions related to the relationship between C and Objective-C (see links below) and I want to start learning C, but apparently there are three types of C (K&R, C89, and C99), and I am wondering which type I should learn to help me with Objective-C. I know from learning Objective-C I unknowingly learned C too, but I want to understand the ins and outs of C more and become familiar with its functions, syntax, features, etc. Also, is Objective-C based off of any one of the three types of C?
Upvotes: 10
Views: 592
Reputation: 1357
There are even more types of C. In the meantime C0X and C11 were defined... They all make only small evolutionary steps from their predecessors, so you shouldn't worry much about it. Objective-C is based on C99 (minus floating point pragmas, actually), so for now that would probably be the best fit.
It's not entirely clear from your question, but you do notice that those variations of C are just evolving specifications from different years? K&R from ca. 1978, C89 from 1989, C99 from 1999 etc... Objective-C was designed to be a strict superset of C, so you can probably expect Objective-C to incorporate C11 features some day.
(NB: several edits to include information from the comments)
Upvotes: 5
Reputation: 76695
I suggest you look at some introductory texts on C, and learn whatever C dialect the text teaches. This will likely be C89 or C99.
K&R C is missing modern features such as "prototypes" (declaring the number and types of arguments to your functions). C89 adds all that stuff in.
C99 has, mostly, small incremental features that are useful in specific domains. The bulk of the stuff you need to learn should be identical across C89 and C99. Fun fact: Microsoft never bothered to implement C99.
Actually, I will suggest a specific introductory text: use the Second Edition of K&R. This basically updates K&R to C89. K&R is an outstanding book, and a great choice for learning the C language.
https://stackoverflow.com/questions/1646667/kr-1st-edition-vs-2nd-edition
Upvotes: 5