Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Preface
How This Book Is Organized
Part I
Part II
Part III
Further Reading
Conventions Used in This Book
Using Code Examples
Safari® Books Online
How to Contact Us
Acknowledgments
Peter
Tony
I. Language
1. Language Basics
Characteristics of C
The Structure of C Programs
Source Files
Comments
Character Sets
Wide Characters and Multibyte Characters
Wide characters
Multibyte characters
Conversion
Universal Character Names
Digraphs and Trigraphs
Identifiers
Identifier Name Spaces
Identifier Scope
How the C Compiler Works
The C Compiler’s Translation Phases
Tokens
2. Types
Typology
Integer Types
Integer Types Defined in Standard Headers
Integer types with exact width (C99)
Floating-Point Types
Complex Floating-Point Types
Enumerated Types
The Type void
void in Function Declarations
Expressions of Type void
Pointers to void
The Alignment of Objects in Memory
3. Literals
Integer Constants
Floating-Point Constants
Decimal Floating-Point Constants
Hexadecimal Floating-Point Constants
Character Constants
Types and Values of Character Constants
Escape Sequences
String Literals
4. Type Conversions
Conversion of Arithmetic Types
Hierarchy of Types
Integer Promotion
Usual Arithmetic Conversions
Other Implicit Type Conversions
The Results of Arithmetic Type Conversions
Conversions to _Bool
Conversions to unsigned integer types other than _Bool
Conversions to signed integer types
Conversions to real floating-point types
Conversions to complex floating-point types
Conversion of Nonarithmetic Types
Array and Function Designators
Explicit Pointer Conversions
Object pointers
Function pointers
Implicit Pointer Conversions
Pointers to void
Pointers to qualified object types
Null pointer constants
Conversions Between Pointer and Integer Types
5. Expressions and Operators
How Expressions Are Evaluated
Generic Selections (C11)
Lvalues
Side Effects and Sequence Points
Operator Precedence and Associativity
Operators in Detail
Arithmetic Operators
Standard arithmetic
Pointer arithmetic
Assignment Operators
Simple assignment
Compound assignments
Increment and Decrement Operators
Comparative Operators
Logical Operators
Bitwise Operators
Boolean bitwise operators
Shift operators
Memory Addressing Operators
The & and * operators
Elements of arrays
Members of structures and unions
Other Operators
Function calls
Compound literals
The sizeof operator
The _Alignof operator
The conditional operator
The comma operator
Constant Expressions
Integer Constant Expressions
Other Constant Expressions
6. Statements
Expression Statements
Block Statements
Loops
while Statements
for Statements
do…while Statements
Nested Loops
Selection Statements
if Statements
switch Statements
Unconditional Jumps
The break Statement
The continue Statement
The goto Statement
The return Statement
7. Functions
Function Definitions
Functions and Storage Class Specifiers
K&R-Style Function Definitions
Function Parameters
Arrays as Function Parameters
The main() Function
Function Declarations
Declaring Optional Parameters
Declaring Variable-Length Array Parameters
How Functions Are Executed
Pointers as Arguments and Return Values
Inline Functions
Non-Returning Functions
Recursive Functions
Variable Numbers of Arguments
8. Arrays
Defining Arrays
Fixed-Length Arrays
Variable-Length Arrays
Accessing Array Elements
Initializing Arrays
Writing Initialization Lists
Initializing Specific Elements
Strings
Multidimensional Arrays
Matrices
Declaring Multidimensional Arrays
Initializing Multidimensional Arrays
Arrays as Arguments of Functions
9. Pointers
Declaring Pointers
Null Pointers
void Pointers
Initializing Pointers
Operations with Pointers
Using Pointers to Read and Modify Objects
Modifying and Comparing Pointers
Pointers and Type Qualifiers
Constant Pointers and Pointers to Constant Objects
Restricted Pointers
Pointers to Arrays and Arrays of Pointers
Array Pointers
Pointer Arrays
Pointers to Functions
10. Structures, Unions, and Bit-Fields
Structures
Defining Structure Types
Structure Objects and typedef Names
Incomplete Structure Types
Accessing Structure Members
Initializing Structures
Initializing Specific Members
Structure Members in Memory
Flexible Structure Members
Pointers as Structure Members
Unions
Defining Union Types
Initializing Unions
Anonymous Structures and Unions
Bit-Fields
11. Declarations
Object and Function Declarations
Examples
Storage Class Specifiers
Type Qualifiers
Declarations and Definitions
Complex Declarators
Type Names
typedef Declarations
_Static_assert Declarations
Linkage of Identifiers
External Linkage
Internal Linkage
No Linkage
Storage Duration of Objects
Static Storage Duration
Thread Storage Duration
Automatic Storage Duration
Initialization
Implicit Initialization
Explicit Initialization
12. Dynamic Memory Management
Allocating Memory Dynamically
Characteristics of Allocated Memory
Resizing and Releasing Memory
An All-Purpose Binary Tree
Characteristics
Implementation
Generating an Empty Tree
Inserting New Data
Finding Data in the Tree
Removing Data from the Tree
Traversing a Tree
A Sample Application
13. Input and Output
Streams
Text Streams
Binary Streams
Files
File Position
Buffers
The Standard Streams
Opening and Closing Files
Opening a File
Access Modes
Closing a File
Reading and Writing
Byte-Oriented and Wide-Oriented Streams
Error Handling
Return values and status flags
The error variable errno
Unformatted I/O
Reading characters
Putting a character back
Writing characters
Reading strings
Writing strings
Reading and writing blocks
Formatted Output
The printf() function family
The format string
Field widths
Printing characters and strings
Printing integers
Printing floating-point numbers
Formatted Input
The scanf() function family
The format string
Field widths
Reading characters and strings
Reading integers
Reading floating-point numbers
Random File Access
Obtaining the Current File Position
Setting the File Access Position
14. Multithreading
Threads
Creating Threads
Other Thread Functions
Accessing Shared Data
Mutual Exclusion
Atomic Objects
Atomic Operations
Memory Ordering
Fences
Communication Between Threads: Condition Variables
Thread-Local Objects and Thread-Specific Storage
Using Thread-Local Objects
Using Thread-Specific Storage
15. Preprocessing Directives
Inserting the Contents of Header Files
How the Preprocessor Finds Header Files
Nested #include Directives
Defining and Using Macros
Macros Without Parameters
Macros with Parameters
Variable numbers of arguments
The stringify operator
The token-pasting operator
Using Macros Within Macros
Macro Scope and Redefinition
Type-generic Macros
Conditional Compiling
The #if and #elif Directives
The defined Operator
The #ifdef and #ifndef Directives
Defining Line Numbers
Generating Error Messages
The #pragma Directive
The _Pragma Operator
Predefined Macros
Conditionally Defined Macros
II. Standard Library
16. The Standard Headers
Using the Standard Headers
Execution Environments
Function and Macro Calls
Reserved Identifiers
Functions with Bounds-Checking
Availability
Runtime Constraints
Contents of the Standard Headers
assert.h
complex.h
ctype.h
errno.h
fenv.h
Macro and type definitions for the floating-point environment
Macro and type definitions for floating-point exceptions
Macro definitions for rounding modes
float.h
Normalized representation of floating-point numbers
Rounding mode and evaluation method
Precision and value range
inttypes.h
Types
Functions
Macros
iso646.h
limits.h
locale.h
math.h
The types float_t and double_t
Classification macros
Other macros in math.h
setjmp.h
signal.h
stdalign.h
stdarg.h
stdatomic.h
Types defined in stdatomic.h
Macros Defined in stdatomic.h
stdbool.h
stddef.h
stdint.h
Value ranges of the integer types with specific widths
Value ranges of other integer types
Macros for integer constants
stdio.h
stdlib.h
stdnoreturn.h
string.h
tgmath.h
threads.h
Types Defined in threads.h
Enumeration constants defined in threads.h
Macros defined in threads.h
time.h
uchar.h
wchar.h
wctype.h
17. Functions at a Glance
Input and Output
Mathematical Functions
Mathematical Functions for Integer Types
Floating-Point Functions
Function-Like Macros
Type-generic macros
Categories of floating-point values
Comparison macros
Pragmas for Arithmetic Operations
The Floating-Point Environment
Accessing status flags
Rounding modes
Saving the whole floating-point environment
Error Handling
Domain errors
Range errors
Character Classification and Conversion
Character Classification
Case Mapping
String Processing
Multibyte Characters
Converting Between Numbers and Strings
Searching and Sorting
Memory Block Handling
Dynamic Memory Management
Date and Time
Process Control
Communication with the Operating System
Signals
Internationalization
Nonlocal Jumps
Multithreading (C11)
Thread Functions
Atomic Operations
Debugging
Error Messages
18. Standard Library Functions
III. Basic Tools
19. Compiling with GCC
The GNU Compiler Collection
Obtaining and Installing GCC
Compiling C Programs with GCC
Step by Step
Preprocessing
Compiling
Assembling
Linking
Non-standard libraries
Passing options to the linker
All of the above
None of the above
Multiple Input Files
File types
Mixed input types
Dynamic Linking and Shared Object Files
Freestanding Programs
C Dialects
Compiler Warnings
Optimization
The -O Levels
The -f Flags
Floating-Point Optimization
Architecture-Specific Optimization
Why Not Optimize?
Debugging
Profiling
Option and Environment Variable Summary
Command-Line Options
Environment Variables
20. Using make to Build C Programs
Targets, Prerequisites, and Commands
The Makefile
Rules
The Command Script
Pattern Rules
Suffix Rules
Built-In Rules
Implicit Rule Chains
Double-Colon Rules
Comments
Variables
Assignment Operators
Variables and Whitespace
Target-Specific Variable Assignments
The Automatic Variables
Other Built-In Variables
Environment Variables
Phony Targets
Other Target Attributes
Macros
Functions
Built-In Functions
Text-processing functions
Filename-manipulation functions
Conditions and flow control functions
Operations on variables
System functions
User-Defined Functions
Directives
Conditionals
Includes
Other Directives
Running make
Generating Header Dependencies
Recursive make Commands
Command-Line Options
Special Targets Used as Runtime Options
GCC Options for Generating Makefile Rules
21. Debugging C Programs with GDB
Installing GDB
A Sample Debugging Session
Symbol Information
Finding a Bug
Starting GDB
Command-Line Arguments
Command-Line Options
Passing arguments to the program being debugged
Selecting files
Selecting the user interface
Executing command scripts
Initialization Files
Using GDB Commands
Command Completion
Displaying Help for Commands
Status Information
Status information on the program being debugged
Status information on the debugger
Running a Program in the Debugger
Displaying Source Code
Working with Breakpoints
Setting and displaying breakpoints
Deleting, disabling, and ignoring breakpoints
Conditional breakpoints
Resuming Execution After a Break
Analyzing the Stack
Displaying a call trace
Displaying and changing the current stack frame
Displaying arguments and local variables
Displaying Data
Displaying values of expressions
Output formats
Displaying memory blocks
Watchpoints: Observing Operations on Variables
Analyzing Core Files in GDB
22. Using an IDE with C
IDEs for C
The Eclipse IDE for C/C++
Installing Eclipse CDT
Running Eclipse
Perspectives and Views
Developing a C Program with Eclipse
Creating a New C Project
Editing
Compiling and Running a Program
Project Properties
Debugging a C Program in Eclipse
Starting the Debugger
Setting Breakpoints
Controlling Program Execution in the Debugger
Further Information on Eclipse
Index
← Prev
Back
Next →
← Prev
Back
Next →