The C Programming Language
CS 1025 Computer Science Fundamentals I
Stephen M. Watt
University of Western Ontario
,The C Programming Language
• A high-level language for writing low-level programs
• Allows machine-independent systems programming
• Operators correspond to popular machine instructions
• Easy to provide efficient compilers
,A Little Bit of History
• 1969-1972: Developed at AT&T Bell Labs by Dennis
Ritchie
– Predecessor B, used word-based addressing.
– C used with development of Unix OS
• 1978: “The C Programming Language” book
by Kernighan and Ritchie
• 1989: ANSI/ISO Standard C89
– Function prototypes, void, enumerations, ...
• 1999: ANSI/ISO Standard C99
– Inline functions, complex numbers, variable length arrays, ...
• 2011: ANSI/ISO Standard C11
– Multithreading, unicode, safety, optionalize some of C99, …
, Comparison to Java
• No objects
• Structs, unions and enumerations instead.
• The three most important things in C: (1) pointers, (2) pointers, (3)
pointers.
• Distinction between structure and pointer to structure.
• Pointer arithmetic. Array/pointer equivalence.
• Strings are arrays of small characters, null terminated.
• C pre-processor
• Setjmp/longjmp functions instead of try/throw.
• register, typedef, volatile, const
• Sizes of integers. Signed and unsigned arithmetic.
• Different IO
CS 1025 Computer Science Fundamentals I
Stephen M. Watt
University of Western Ontario
,The C Programming Language
• A high-level language for writing low-level programs
• Allows machine-independent systems programming
• Operators correspond to popular machine instructions
• Easy to provide efficient compilers
,A Little Bit of History
• 1969-1972: Developed at AT&T Bell Labs by Dennis
Ritchie
– Predecessor B, used word-based addressing.
– C used with development of Unix OS
• 1978: “The C Programming Language” book
by Kernighan and Ritchie
• 1989: ANSI/ISO Standard C89
– Function prototypes, void, enumerations, ...
• 1999: ANSI/ISO Standard C99
– Inline functions, complex numbers, variable length arrays, ...
• 2011: ANSI/ISO Standard C11
– Multithreading, unicode, safety, optionalize some of C99, …
, Comparison to Java
• No objects
• Structs, unions and enumerations instead.
• The three most important things in C: (1) pointers, (2) pointers, (3)
pointers.
• Distinction between structure and pointer to structure.
• Pointer arithmetic. Array/pointer equivalence.
• Strings are arrays of small characters, null terminated.
• C pre-processor
• Setjmp/longjmp functions instead of try/throw.
• register, typedef, volatile, const
• Sizes of integers. Signed and unsigned arithmetic.
• Different IO