C language tutorial


C language tutorial







Table of Contents:




1. Chapter 1: A Tutorial Introduction:

1. Getting Started
2. Variables and Arithmetic Expressions
3. The for statement
4. Symbolic Constants
5. Character Input and Output
1. File Copying
2. Character Counting
3. Line Counting
4. Word Counting
6. Arrays
7. Functions
8. Arguments - Call by Value
9. Character Arrays
10. External Variables and Scope

2. Chapter 2: Types, Operators and Expressions:

1. Variable Names
2. Data Types and Sizes
3. Constants
4. Declarations
5. Arithmetic Operators
6. Relational and Logical Operators
7. Type Conversions
8. Increment and Decrement Operators
9. Bitwise Operators
10. Assignment Operators and Expressions
11. Conditional Expressions
12. Precedence and Order of Evaluation

3. Chapter 3: Control Flow:

1. Statements and Blocks
2. If-Else
3. Else-If
4. Switch
5. Loops - While and For
6. Loops - Do-While
7. Break and Continue
8. Goto and labels

4. Chapter 4: Functions and Program Structure

1. Basics of Functions
2. Functions Returning Non-integers
3. External Variables
4. Scope Rules
5. Header Files
6. Static Variables
7. Register Variables
8. Block Structure
9. Initialization
10. Recursion
11. The C Preprocessor
1. File Inclusion
2. Macro Substitution
3. Conditional Inclusion

5. Chapter 5: Pointers and Arrays:

1. Pointers and Addresses
2. Pointers and Function Arguments
3. Pointers and Arrays
4. Address Arithmetic
5. Character Pointers and Functions
6. Pointer Arrays; Pointers to Pointers
7. Multi-dimensional Arrays
8. Initialization of Pointer Arrays
9. Pointers vs. Multi-dimensional Arrays
10. Command-line Arguments
11. Pointers to Functions
12. Complicated Declarations

6. Chapter 6: Structures:

1. Basics of Structures
2. Structures and Functions
3. Arrays of Structures
4. Pointers to Structures
5. Self-referential Structures
6. Table Lookup
7. Typedef
8. Unions
9. Bit-fields

7. Chapter 7: Input and Output

1. Standard Input and Output
2. Formatted Output - printf
3. Variable-length Argument Lists
4. Formatted Input - Scanf
5. File Access
6. Error Handling - Stderr and Exit
7. Line Input and Output
8. Miscellaneous Functions
1. String Operations
2. Character Class Testing and Conversion
3. Ungetc
4. Command Execution
5. Storage Management
6. Mathematical Functions
7. Random Number generation

8. Chapter 8: The UNIX System Interface

1. File Descriptors
2. Low Level I/O - Read and Write
3. Open, Creat, Close, Unlink
4. Random Access - Lseek
5. Example - An implementation of Fopen and Getc
6. Example - Listing Directories
7. Example - A Storage Allocator

Appendix A: Reference Manual
1. Introduction
2. Lexical Conventions
3. Syntax Notation
4. Meaning of Identifiers
5. Objects and Lvalues
6. Conversions
7. Expressions
8. Declarations
9. Statements
10. External Declarations
11. Scope and Linkage
12. Preprocessor
13. Grammar

--------------------------------------------


Sample of the pdf document :








Introduction:

C is a general-purpose programming language. It has been closely associated with the UNIX operating system where it was developed, since both the system and most of the programs that run on it are written in C.
The language, however, is not tied to any one operating system or machine; and although it has been called a ‘‘system programming language’’ because it is useful for writing compilers and operating systems, it has been used equally well to write major programs in many different domains.

Many of the important ideas of C stem from the language BCPL, developed by Martin Richards. The influence of BCPL on C proceeded indirectly through the language B, which was written by Ken Thompson in 1970 for the first UNIX system on the DEC PDP-7.

BCPL and B are ‘‘typeless’’ languages. By contrast, C provides a variety of data types. The fundamental types are characters,
and integers and floating point numbers of several sizes. In addition, there is a hierarchy of derived data types created with pointers, arrays, structures and unions. Expressions are formed from operators and operands; any expression, including an assignment or a function call, can be a statement. Pointers provide for machine-independent address arithmetic.

C provides the fundamental control-flow constructions required for well-structured programs: statement grouping, decision making (if-else), selecting one of a set of possible values (switch), looping with the termination test at the top (while,for) or at the bottom (do), and early loop exit (break).

Functions may return values of basic types, structures, unions, or pointers. Any function may be called recursively. Local variables are typically ‘‘automatic’’, or created anew with each invocation. Function definitions may not be nested but variables may be declared in a block-structured fashion. The functions of a C program may exist in separate source files that are compiled separately. Variables may be internal to a function, external but known only within a single source file, or visible to the entire program.

A preprocessing step performs macro substitution on program text, inclusion of other source files, and conditional compilation.

C is a relatively ‘‘low-level’’ language. This characterization is not pejorative; it simply means that C deals with the same sort of objects that most computers do, namely characters, numbers, and addresses. These may be combined and moved about with the arithmetic and logical operators implemented by real machines.
C provides no operations to deal directly with composite objects such as character strings, sets, lists or arrays.

There are no operations that manipulate an entire array or string, although structures may be copied as a unit. The language does not define any storage allocation facility other than static definition and the stack discipline provided by the local variables of functions; there is no heap or garbage collection. Finally, C itself provides no input/output facilities; there are no READ or WRITE statements, and no built-in file access methods. All of these higher-level mechanisms must be provided by explicitly called functions. Most C implementations have included a reasonably standard collection of such functions.

Similarly, C offers only straightforward, single-thread control flow: tests, loops, grouping, and subprograms, but not multiprogramming, parallel operations, synchronization, or coroutines.
Although the absence of some of these features may seem like a grave deficiency, (‘‘You mean I have to call a function to compare two character strings?’’), keeping the language down to modest size has real benefits. Since C is relatively small, it can be described in small space, and learned quickly. A programmer can reasonably expect to know and understand and indeed regularly use the entire language.

For many years, the definition of C was the reference manual in the first edition of The C Programming Language. In 1983, the American National Standards Institute (ANSI) established a committee to provide a modern, comprehensive definition of C.

 The resulting definition, the ANSI standard, or ‘‘ANSI C’’, was completed in late 1988. Most of the features of the standard are already supported by modern compilers.

The standard is based on the original reference manual. The language is relatively little changed; one of the goals of the standard was to make sure that most existing programs would remain valid, or, failing that, that compilers could produce warnings of new behavior.







 Click here for  Download PDF / FREE


C language tutorial


0 commentaires: