History of c
-Ritchie and Thompson 1973
Rewrite UNIX kernel with C
-Richie and Kernaghan
Created the “C programming language”
C
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
Run time features
-easy to adapt a C compilers output to the execution environment on a platform
Missing features
Aggregate data types
Static and extern
- external linkage
Addresses and pointers
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
- block is curly brackets
C preprocessor
- allows macro processing, inclusion of additional C source files, conditional compilation
Macro processing
- 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
Abstract data type
-an abstract data type is a set of operations which access a collection of stored data
FILE *fopen(char *filename, char *mode)
char *fgets(char *buf, int n, FILE *stream)
int scanf(char *format, […])
printf(char *format, […])
int fprintf(FILE *stream, char *format, […])
-like printf but output goes to already opened stream
int fputc(int c, FILE *stream)
int fclose(FILE *stream)