Next:
Contents
TUTORIAL C
Gordon Dodrill
Nov 21, 1987
Contents
Introduction
Getting Started
What is an identifier ?
What about the underline ?
How this tutorial is written
A discussion of some of the files ccl.bat
Getting started in C
Your first c program
A program that does something
Another program with more output
Lets print some numbers
How do we print numbers
How do we add comments in C
Good formatting style
Programming exercises
Program Control
The while loop
The do-while loop
The for loop
The if statement
Now for the if-else
The switch statement
Finally, a meaningful program
Another poor programming example
Programming exercises
Assignment and Logical compares
Integer assignment statements
Additional data types
Data type mixing
How to use the new data types
Lots of variable types
The conversion characters
Logical compares
More compares
Additional compare concepts
Logical evaluation
Precedence of operators
This is a trick, be careful
Potential problem areas
The cryptic part of C
The cryptic arithmetic operator
The conditional expression
To be cryptic or not to be cryptic
Programming exercises
Functions, variables, and prototypes
Our first user defined function
Defining the functions
Passing a value to a function
More about passing a value to a function
Now to confess a little lie
Floating point functions
There is a bug in the first version of Turbo C
Scope of variables
More on "automatic" variables
What are static variables?
Using the same name again
What is a register variable?
Where do i define variables?
What is prototyping?
Standard function libraries
What is recursion ?
What did it do ?
Another example of recursion
How to work around the Turbo C (v1.0) bug
Programming exercises
Defines and Macros
Defines and macros are aids to clear programming
Is this really useful ?
What is a macro ?
Lets look at a wrong macro
What is an enumeration variable ?
Programming exercises
Strings and Arrays
What is a string ?
What is an array ?
How do we use the string ?
Outputting part of a string
Some string subroutines
Alphabetical sorting of strings
Combining strings
An array of integers
An array of floating point data
Getting data back from a function
Arrays pass data both ways
A hint at a future lesson
Multiply dimensioned arrays
Programming exercises
Pointers
What is a pointer ?
Another pointer
There is only one variable
How do you declare a pointer ?
The second program with pointers
A string variable is actually a pointer
Pointer arithmetic
Function data return with a pointer
Pointers are valuable
Programming exercises
Standard Input/Output
The stdio.h header file
Input/output operations in c
Other include files
Back to the file named "simpleio.c"
Dos is helping us out (or getting in the way)
Another strange I/O method
Now we need a line feed
Now to read in some integers
Character string input
Input/Output programming in C
In memory I/O
Is that really useful ?
Standard error output
What about the exit(4) statement?
Programming exercise
File Input/Output
Output to a file
Opening a file
Reading ("r")
Writing ("w")
Outputting to the file
Closing a file
The "putc" function
Reading a file
Caution Caution Caution
Reading a word at a time
This is a problem
Finally, we read a full line
How to use a variable filename
How do we print ?
Programming exercises
Structures and Unions
What is a structure ?
A single compound variable
Assigning values to the variables
How do we use the resulting data ?
An array of structures
A recent upgrade to the C language
We finally display all of the results
Using pointers and structures together
Pointer arithmetic
Nested and named structures
Two more variables
How to use some of the fields
More about structures
What are unions ?
Another union example
A new concept, the typedef
What do we have now ?
What is a bitfield ?
What is the bitfield good for ?
Programming exercises
Dynamic Allocation
What is dynamic allocation ?
Dynamic variable creation
What is a heap ?
More about segments
Back to the "malloc" function
What is a cast ?
Getting rid of the dynamically allocated data
That was a lot of discussion
An array of pointers
A linked list
The data definitions
The first field
Filling additional structures
Printing the data out
More about dynamic allocation and linked lists
Another new function - calloc
Programming exercises
Character and Bit Manipulation
Upper and lower case
Classification of characters
The logical functions
The shift instructions
Example Programs
Why this chapter ?
dosex.c - The DOS Example Program
whatnext.c - The Batch File Interrogator
list.c - The Program Lister
vc.c - The Visual Calculator
About this document ...
Admin.NET
Mon Feb 20 10:44:07 MET 1995