| |  | Copyright |
| |  | Preface |
| |
|  | How This Book Is Organized |
| |
|  | Further Reading |
| |
|  | Conventions Used in This Book |
| |
|  | Using Code Examples |
| |
|  | Safari® Enabled |
| |
|  | Your Questions and Comments |
| |
|  | Acknowledgments |
| |  |
Part I:
Language |
| |
|  |
Chapter 1.
Language Basics |
| |
|  |
Section 1.1.
Characteristics of C |
| |
|  |
Section 1.2.
The Structure of C Programs |
| |
|  |
Section 1.3.
Source Files |
| |
|  |
Section 1.4.
Comments |
| |
|  |
Section 1.5.
Character Sets |
| |
|  |
Section 1.6.
Identifiers |
| |
|  |
Section 1.7.
How the C Compiler Works |
| |
|  |
Chapter 2.
Types |
| |
|  |
Section 2.1.
Typology |
| |
|  |
Section 2.2.
Integer Types |
| |
|  |
Section 2.3.
Floating-Point Types |
| |
|  |
Section 2.4.
Complex Floating-Point Types (C99) |
| |
|  |
Section 2.5.
Enumerated Types |
| |
|  |
Section 2.6.
The Type void |
| |
|  |
Chapter 3.
Literals |
| |
|  |
Section 3.1.
Integer Constants |
| |
|  |
Section 3.2.
Floating-Point Constants |
| |
|  |
Section 3.3.
Character Constants |
| |
|  |
Section 3.4.
String Literals |
| |
|  |
Chapter 4.
Type Conversions |
| |
|  |
Section 4.1.
Conversion of Arithmetic Types |
| |
|  |
Section 4.2.
Conversion of Nonarithmetic Types |
| |
|  |
Chapter 5.
Expressions and Operators |
| |
|  |
Section 5.1.
How Expressions Are Evaluated |
| |
|  |
Section 5.2.
Operators in Detail |
| |
|  |
Section 5.3.
Constant Expressions |
| |
|  |
Chapter 6.
Statements |
| |
|  |
Section 6.1.
Expression Statements |
| |
|  |
Section 6.2.
Block Statements |
| |
|  |
Section 6.3.
Loops |
| |
|  |
Section 6.4.
Selection Statements |
| |
|  |
Section 6.5.
Unconditional Jumps |
| |
|  |
Chapter 7.
Functions |
| |
|  |
Section 7.1.
Function Definitions |
| |
|  |
Section 7.2.
Function Declarations |
| |
|  |
Section 7.3.
How Functions Are Executed |
| |
|  |
Section 7.4.
Pointers as Arguments and Return Values |
| |
|  |
Section 7.5.
Inline Functions |
| |
|  |
Section 7.6.
Recursive Functions |
| |
|  |
Section 7.7.
Variable Numbers of Arguments |
| |
|  |
Chapter 8.
Arrays |
| |
|  |
Section 8.1.
Defining Arrays |
| |
|  |
Section 8.2.
Accessing Array Elements |
| |
|  |
Section 8.3.
Initializing Arrays |
| |
|  |
Section 8.4.
Strings |
| |
|  |
Section 8.5.
Multidimensional Arrays |
| |
|  |
Section 8.6.
Arrays as Arguments of Functions |
| |
|  |
Chapter 9.
Pointers |
| |
|  |
Section 9.1.
Declaring Pointers |
| |
|  |
Section 9.2.
Operations with Pointers |
| |
|  |
Section 9.3.
Pointers and Type Qualifiers |
| |
|  |
Section 9.4.
Pointers to Arrays and Arrays of Pointers |
| |
|  |
Section 9.5.
Pointers to Functions |
| |
|  |
Chapter 10.
Structures and Unions and Bit-Fields |
| |
|  |
Section 10.1.
Structures |
| |
|  |
Section 10.2.
Unions |
| |
|  |
Section 10.3.
Bit-Fields |
| |
|  |
Chapter 11.
Declarations |
| |
|  |
Section 11.1.
General Syntax |
| |
|  |
Section 11.2.
Type Names |
| |
|  |
Section 11.3.
typedef Declarations |
| |
|  |
Section 11.4.
Linkage of Identifiers |
| |
|  |
Section 11.5.
Storage Duration of Objects |
| |
|  |
Section 11.6.
Initialization |
| |
|  |
Chapter 12.
Dynamic Memory Management |
| |
|  |
Section 12.1.
Allocating Memory Dynamically |
| |
|  |
Section 12.2.
Characteristics of Allocated Memory |
| |
|  |
Section 12.3.
Resizing and Releasing Memory |
| |
|  |
Section 12.4.
An All-Purpose Binary Tree |
| |
|  |
Section 12.5.
Characteristics |
| |
|  |
Section 12.6.
Implementation |
| |
|  |
Chapter 13.
Input and Output |
| |
|  |
Section 13.1.
Streams |
| |
|  |
Section 13.2.
Files |
| |
|  |
Section 13.3.
Opening and Closing Files |
| |
|  |
Section 13.4.
Reading and Writing |
| |
|  |
Section 13.5.
Random File Access |
| |
|  |
Chapter 14.
Preprocessing Directives |
| |
|  |
Section 14.1.
Inserting the Contents of Header Files |
| |
|  |
Section 14.2.
Defining and Using Macros |
| |
|  |
Section 14.3.
Conditional Compiling |
| |
|  |
Section 14.4.
Defining Line Numbers |
| |
|  |
Section 14.5.
Generating Error Messages |
| |
|  |
Section 14.6.
The #pragma Directive |
| |
|  |
Section 14.7.
The _Pragma Operator |
| |
|  |
Section 14.8.
Predefined Macros |
| |  |
Part II:
Standard Library |
| |
|  |
Chapter 15.
The Standard Headers |
| |
|  |
Section 15.1.
Using the Standard Headers |
| |
|  |
Section 15.2.
Contents of the Standard Headers |
| |
|  |
Chapter 16.
Functions at a Glance |
| |
|  |
Section 16.1.
Input and Output |
| |
|  |
Section 16.2.
Mathematical Functions |
| |
|  |
Section 16.3.
Character Classification and Conversion |
| |
|  |
Section 16.4.
String Processing |
| |
|  |
Section 16.5.
Multibyte Characters |
| |
|  |
Section 16.6.
Converting Between Numbers and Strings |
| |
|  |
Section 16.7.
Searching and Sorting |
| |
|  |
Section 16.8.
Memory Block Handling |
| |
|  |
Section 16.9.
Dynamic Memory Management |
| |
|  |
Section 16.10.
Date and Time |
| |
|  |
Section 16.11.
Process Control |
| |
|  |
Section 16.12.
Internationalization |
| |
|  |
Section 16.13.
Nonlocal Jumps |
| |
|  |
Section 16.14.
Debugging |
| |
|  |
Section 16.15.
Error Messages |
| |
|  |
Chapter 17.
Standard Library Functions |
| |
|  | _Exit |
| |
|  | abort |
| |
|  | abs |
| |
|  | acos |
| |
|  | acosh |
| |
|  | asctime |
| |
|  | asin |
| |
|  | asinh |
| |
|  | assert |
| |
|  | atan |
| |
|  | atan2 |
| |
|  | atanh |
| |
|  | atexit |
| |
|  | atof |
| |
|  | atoi |
| |
|  | atol, atoll |
| |
|  | bsearch |
| |
|  | btowc |
| |
|  | cabs |
| |
|  | cacos |
| |
|  | cacosh |
| |
|  | calloc |
| |
|  | carg |
| |
|  | casin |
| |
|  | casinh |
| |
|  | catan |
| |
|  | catanh |
| |
|  | cbrt |
| |
|  | ccos |
| |
|  | ccosh |
| |
|  | ceil |
| |
|  | cexp |
| |
|  | cimag |
| |
|  | clearerr |
| |
|  | clock |
| |
|  | conj |
| |
|  | copysign |
| |
|  | cos |
| |
|  | cosh |
| |
|  | cpow |
| |
|  | cproj |
| |
|  | creal |
| |
|  | csin |
| |
|  | csinh |
| |
|  | csqrt |
| |
|  | ctan |
| |
|  | ctanh |
| |
|  | ctime |
| |
|  | difftime |
| |
|  | div |
| |
|  | erf |
| |
|  | erfc |
| |
|  | exit |
| |
|  | exp |
| |
|  | exp2 |
| |
|  | expm1 |
| |
|  | fabs |
| |
|  | fclose |
| |
|  | fdim |
| |
|  | feclearexcept |
| |
|  | fegetenv |
| |
|  | fegetexceptflag |
| |
|  | fegetround |
| |
|  | feholdexcept |
| |
|  | feof |
| |
|  | feraiseexcept |
| |
|  | ferror |
| |
|  | fesetenv |
| |
|  | fesetexceptflag |
| |
|  | fesetround |
| |
|  | fetestexcept |
| |
|  | feupdateenv |
| |
|  | fflush |
| |
|  | fgetc |
| |
|  | fgetpos |
| |
|  | fgets |
| |
|  | fgetwc |
| |
|  | fgetws |
| |
|  | floor |
| |
|  | fma |
| |
|  | fmax |
| |
|  | fmin |
| |
|  | fmod |
| |
|  | fopen |
| |
|  | fpclassify |
| |
|  | fprintf |
| |
|  | fputc |
| |
|  | fputs |
| |
|  | fputwc |
| |
|  | fputws |
| |
|  | fread |
| |
|  | free |
| |
|  | freopen |
| |
|  | frexp |
| |
|  | fscanf |
| |
|  | fseek |
| |
|  | fsetpos |
| |
|  | ftell |
| |
|  | fwide |
| |
|  | fwprintf |
| |
|  | fwscanf |
| |
|  | fwrite |
| |
|  | getc |
| |
|  | getchar |
| |
|  | getenv |
| |
|  | gets |
| |
|  | getwc |
| |
|  | getwchar |
| |
|  | gmtime |
| |
|  | hypot |
| |
|  | ilogb |
| |
|  | imaxabs |
| |
|  | imaxdiv |
| |
|  | isalnum |
| |
|  | isalpha |
| |
|  | isblank |
| |
|  | iscntrl |
| |
|  | isdigit |
| |
|  | isfinite |
| |
|  | isgraph |
| |
|  | isgreater, isgreaterequal |
| |
|  | isinf |
| |
|  | isless, islessequal, islessgreater |
| |
|  | islower |
| |
|  | isnan |
| |
|  | isnormal |
| |
|  | isprint |
| |
|  | ispunct |
| |
|  | isspace |
| |
|  | isunordered |
| |
|  | isupper |
| |
|  | iswalnum |
| |
|  | iswalpha |
| |
|  | iswblank |
| |
|  | iswcntrl |
| |
|  | iswctype |
| |
|  | iswdigit |
| |
|  | iswgraph |
| |
|  | iswlower |
| |
|  | iswprint |
| |
|  | iswpunct |
| |
|  | iswspace |
| |
|  | iswupper |
| |
|  | iswxdigit |
| |
|  | isxdigit |
| |
|  | labs |
| |
|  | ldexp |
| |
|  | ldiv |
| |
|  | llabs |
| |
|  | lldiv |
| |
|  | llrint |
| |
|  | llround |
| |
|  | localeconv |
| |
|  | localtime |
| |
|  | log |
| |
|  | log10 |
| |
|  | log1p |
| |
|  | log2 |
| |
|  | logb |
| |
|  | longjmp |
| |
|  | lrint |
| |
|  | lround |
| |
|  | malloc |
| |
|  | mblen |
| |
|  | mbrlen |
| |
|  | mbrtowc |
| |
|  | mbsinit |
| |
|  | mbsrtowcs |
| |
|  | mbstowcs |
| |
|  | mbtowc |
| |
|  | memchr |
| |
|  | memcmp |
| |
|  | memcpy |
| |
|  | memmove |
| |
|  | memset |
| |
|  | mktime |
| |
|  | modf |
| |
|  | nearbyint |
| |
|  | nextafter |
| |
|  | nexttoward |
| |
|  | perror |
| |
|  | pow |
| |
|  | printf |
| |
|  | putc |
| |
|  | putchar |
| |
|  | puts |
| |
|  | putwc |
| |
|  | putwchar |
| |
|  | qsort |
| |
|  | raise |
| |
|  | rand |
| |
|  | realloc |
| |
|  | remainder |
| |
|  | remove |
| |
|  | remquo |
| |
|  | rename |
| |
|  | rewind |
| |
|  | rint |
| |
|  | round |
| |
|  | scalbln, scalbn |
| |
|  | scanf |
| |
|  | setbuf |
| |
|  | setjmp |
| |
|  | setlocale |
| |
|  | setvbuf |
| |
|  | signal |
| |
|  | signbit |
| |
|  | sin |
| |
|  | sinh |
| |
|  | snprintf |
| |
|  | sprintf |
| |
|  | sqrt |
| |
|  | srand |
| |
|  | sscanf |
| |
|  | strcat |
| |
|  | strchr |
| |
|  | strcmp |
| |
|  | strcoll |
| |
|  | strcpy |
| |
|  | strcspn |
| |
|  | strerror |
| |
|  | strftime |
| |
|  | strlen |
| |
|  | strncat |
| |
|  | strncmp |
| |
|  | strncpy |
| |
|  | strpbrk |
| |
|  | strrchr |
| |
|  | strspn |
| |
|  | strstr |
| |
|  | strtod, strtof, strtold |
| |
|  | strtoimax |
| |
|  | strtok |
| |
|  | strtol, strtoll |
| |
|  | strtoul, strtoull |
| |
|  | strtoumax |
| |
|  | strxfrm |
| |
|  | swprintf |
| |
|  | swscanf |
| |
|  | system |
| |
|  | tan |
| |
|  | tanh |
| |
|  | time |
| |
|  | tmpfile |
| |
|  | tmpnam |
| |
|  | tolower |
| |
|  | toupper |
| |
|  | towctrans |
| |
|  | towlower |
| |
|  | towupper |
| |
|  | trunc |
| |
|  | ungetc |
| |
|  | ungetwc |
| |
|  | va_arg, va_copy, va_end, va_start |
| |
|  | vfprintf, vprintf, vsnprintf, vsprintf |
| |
|  | vfscanf, vscanf, vsscanf |
| |
|  | vfwprintf, vswprintf, vwprintf |
| |
|  | vfwscanf, vswscanf, vwscanf |
| |
|  | wcrtomb |
| |
|  | wcscat |
| |
|  | wcschr |
| |
|  | wcscmp |
| |
|  | wcscoll |
| |
|  | wcscpy |
| |
|  | wcscspn |
| |
|  | wcsftime |
| |
|  | wcslen |
| |
|  | wcsncat |
| |
|  | wcsncmp |
| |
|  | wcsncpy |
| |
|  | wcspbrk |
| |
|  | wcsrchr |
| |
|  | wcsrtombs |
| |
|  | wcsspn |
| |
|  | wcsstr |
| |
|  | wcstod, wcstof, wcstold |
| |
|  | wcstoimax |
| |
|  | wcstok |
| |
|  | wcstol, wcstoll |
| |
|  | wcstold |
| |
|  | wcstoll |
| |
|  | wcstombs |
| |
|  | wcstoul, wcstoull |
| |
|  | wcstoumax |
| |
|  | wcsxfrm |
| |
|  | wctob |
| |
|  | wctomb |
| |
|  | wctrans |
| |
|  | wctype |
| |
|  | wmemchr |
| |
|  | wmemcmp |
| |
|  | wmemcpy |
| |
|  | wmemmove |
| |
|  | wmemset |
| |
|  | wprintf |
| |
|  | wscanf |
| |  |
Part III:
Basic Tools |
| |
|  |
Chapter 18.
Compiling with GCC |
| |
|  |
Section 18.1.
The GNU Compiler Collection |
| |
|  |
Section 18.2.
Obtaining and Installing GCC |
| |
|  |
Section 18.3.
Compiling C Programs with GCC |
| |
|  |
Section 18.4.
C Dialects |
| |
|  |
Section 18.5.
Compiler Warnings |
| |
|  |
Section 18.6.
Optimization |
| |
|  |
Section 18.7.
Debugging |
| |
|  |
Section 18.8.
Profiling |
| |
|  |
Section 18.9.
Option and Environment Variable Summary |
| |
|  |
Chapter 19.
Using make to Build C Programs |
| |
|  |
Section 19.1.
Targets, Prerequisites, and Commands |
| |
|  |
Section 19.2.
The Makefile |
| |
|  |
Section 19.3.
Rules |
| |
|  |
Section 19.4.
Comments |
| |
|  |
Section 19.5.
Variables |
| |
|  |
Section 19.6.
Phony Targets |
| |
|  |
Section 19.7.
Other Target Attributes |
| |
|  |
Section 19.8.
Macros |
| |
|  |
Section 19.9.
Functions |
| |
|  |
Section 19.10.
Directives |
| |
|  |
Section 19.11.
Running make |
| |
|  |
Chapter 20.
Debugging C Programs with GDB |
| |
|  |
Section 20.1.
Installing GDB |
| |
|  |
Section 20.2.
A Sample Debugging Session |
| |
|  |
Section 20.3.
Starting GDB |
| |
|  |
Section 20.4.
Using GDB Commands |
| |  | About the Authors |
| |  | Colophon |
| |  | Index |