C Flashcards
History of c
-Ritchie and Thompson 1973
Rewrite UNIX kernel with C
-Richie and Kernaghan
Created the “C programming language”
C
- general purpose language
- equally usable for applications programming and systems programming (network protocol, database management system, write a compiler)
- ubiquitous (where find C you find UNIX)
Features of C
-most toolchains have relatively small footprint
Popular choice for developing embedded systems
Operating systems research and development
Good choice for systems programs that one expects to port
Compile time features
- ANSI-compliant compilers provide extensive compile-time diagnostics
- also provide a continuum of optimizations
Run time features
-easy to adapt a C compilers output to the execution environment on a platform
Missing features
- no native array bounds checking
- no null pointer checkers
- no uninitialized vars check
Aggregate data types
- struct: one mechanism to declare user-defined types
- arrays: can be set scaler or aggregate
- union: similar to structs, but members are overlaid
Static and extern
- internal linkage
- external linkage
Addresses and pointers
- All bars refer to data
- All data resides in memory
- Every memory location has an address
- C exposes these details for us to use
Program scope
Var exists for programs lifetime and can be accessed from other files (extern)
File scope
Visible from its declaration to end of source file
Static
Function scope
Visible from begging to end of function
Block scope
- visible from form declaration to end of the block
- block is curly brackets
C preprocessor
- separate program that runs before the compiler
- allows macro processing, inclusion of additional C source files, conditional compilation
Macro processing
- a name that has an associated text string
- macros introduced from #define
Standard headers
Stdio.h : standard I/O library funcs Math.h : math funcs Stdlib.h : memory allocation funcs and general utility funcs string.h : string funcs ctype.h : char testing and mapping funcs