1 Getting Started ..................................................................................... 1-1
1.1 C Boot Disk ...................................................................................................... 1-1
1.2 What Is An Identifier? ................................................................................... 1-2
1.3 What About The Underline? ......................................................................... 1-2
1.4 How This Tutorial Is Written ........................................................................ 1-2
1.5 A Discussion Of Some Of The Files .............................................................. 1-3
1.6 List.xrel ............................................................................................................ 1-3
2 Getting started in C ............................................................................. 2-1
2.1 Your First C Program .................................................................................... 2-1
2.2 A Program That Does Something ................................................................. 2-1
2.3 Another Program With More Output .......................................................... 2-2
2.4 To Print Some Numbers ................................................................................. 2-2
2.5 How Do We Print Numbers ........................................................................... 2-3
2.6 How Do We Add Comments In C ................................................................. 2-3
2.7 Good Formatting Style ................................................................................... 2-4
2.8 Programming Exercises ................................................................................. 2-5
3 Program Control .................................................................................. 3-1
3.1 The While Loop .............................................................................................. 3-1
3.2 The Do-While Loop ........................................................................................ 3-1
3.3 The For Loop .................................................................................................. 3-2
3.4 The If Statement ............................................................................................. 3-2
3.5 Now For The If-Else ....................................................................................... 3-3
3.6 The Break And Continue ............................................................................... 3-3
3.7 The Switch Statement ..................................................................................... 3-4
3.8 The Goto Statement ........................................................................................ 3-4
3.9 Finally, A Meaningful Program .................................................................... 3-5
3.10 Another Poor Programming Example ........................................................ 3-6
3.11 Programming Exercises ............................................................................... 3-7
4 Assignment & Logical compares ........................................................ 4-1
4.1 Integer Assignment Statements ..................................................................... 4-1
4.2 Additional Data Types .................................................................................... 4-2
4.3 Data Type Mixing ........................................................................................... 4-2
4.4 How To Use The New Data Types ................................................................. 4-3
4.5 Characteristics of Variable Types ................................................................. 4-3
4.6 Lots Of Variable Types .................................................................................. 4-3
4.7 The Conversion Characters ........................................................................... 4-5
4.8 Logical Compares ........................................................................................... 4-5
4.9 More Compares .............................................................................................. 4-6
4.10 Additional Compare Concepts .................................................................... 4-7
4.11 Logical Evaluation ........................................................................................ 4-7
4.12 Precedence Of Operators ............................................................................. 4-7
4.13 This Is A Trick, Be Careful .......................................................................... 4-8
4.14 Potential Problem Areas .............................................................................. 4-8
4.15 The Cryptic Part Of C .................................................................................. 4-8
4.16 The Cryptic Arithmetic Operator ............................................................... 4-9
4.17 The Conditional Expression ........................................................................ 4-9
4.18 To Be Cryptic Or Not To Be Cryptic .......................................................... 4-10
4.19 Programming Exercises ............................................................................... 4-10
C Tutorial i
5 Functions and variables ....................................................................... 5-1
5.1 Our First User Defined Function .................................................................. 5-1
5.2 Defining The Functions .................................................................................. 5-2
5.3 Passing A Value To A Function ..................................................................... 5-2
5.4 More About Passing A Value To A Function ............................................... 5-2
5.5 Now To Confess A Little Lie .......................................................................... 5-3
5.6 Floating Point Functions ................................................................................ 5-4
5.7 Scope Of Variables ......................................................................................... 5-5
5.8 More On "Automatic" Variables .................................................................. 5-6
5.9 What Are Static Variables? ........................................................................... 5-6
5.10 Using The Same Name Again ...................................................................... 5-6
5.11 What Is A Register Variable? ...................................................................... 5-6
5.12 Where Do I Define Variables? ..................................................................... 5-7
5.13 Standard Function Libraries ....................................................................... 5-7
5.14 What Is Recursion? ...................................................................................... 5-7
5.15 What Did It Do? ............................................................................................ 5-8
5.16 Another Example Of Recursion .................................................................. 5-8
5.17 Programming Exercises ............................................................................... 5-9
6 Defines and Macros .............................................................................. 6-1
6.1 Defines And Macros Are Aids To Clear Programming .............................. 6-1
6.2 Is This Really Useful? ..................................................................................... 6-1
6.3 What Is A Macro? .......................................................................................... 6-2
6.4 Lets Look At A Wrong Macro ....................................................................... 6-2
6.5 Programming Exercise ................................................................................... 6-3
7 Strings and Arrays ............................................................................... 7-1
7.1 What Is A String? ........................................................................................... 7-1
7.2 What Is An Array? ......................................................................................... 7-1
7.3 How Do We Use The String? ......................................................................... 7-1
7.4 Outputting Part Of A String .......................................................................... 7-2
7.5 Some String Subroutines ................................................................................ 7-2
7.6 Alphabetical Sorting Of Strings .................................................................... 7-3
7.7 Combining Strings .......................................................................................... 7-3
7.8 An Array Of Integers ..................................................................................... 7-3
7.9 An Array Of Floating Point Data .................................................................. 7-4
7.10 Getting Data Back From A Function .......................................................... 7-4
7.11 Arrays Pass Data Both Ways ....................................................................... 7-5
7.12 A Hint At A Future Lesson .......................................................................... 7-5
7.13 Multiply Dimensioned Arrays ..................................................................... 7-6
7.14 Programming Exercises ............................................................................... 7-6
8 Pointers ................................................................................................. 8-1
8.1 What Is A Pointer? ......................................................................................... 8-1
8.2 Two Very Important Rules ............................................................................ 8-1
8.3 Memory Aids ................................................................................................... 8-1
8.4 Another Pointer .............................................................................................. 8-2
8.5 There Is Only One Variable .......................................................................... 8-2
8.6 How Do You Declare A Pointer? ................................................................... 8-2
8.7 The Second Program With Pointers ............................................................. 8-3
8.8 A String Variable Is Actually A Pointer ....................................................... 8-3
8.9 Pointer Arithmetic .......................................................................................... 8-4
8.10 Now For An Integer Pointer ........................................................................ 8-4
8.11 Function Data Return With A Pointer ....................................................... 8-4
8.12 Pointers Are Valuable .................................................................................. 8-5
C Tutorial ii
8.13 Programming Exercises ............................................................................... 8-5
9 Standard Input/Output ....................................................................... 9-1
9.1 The Stdio.H Header File ................................................................................ 9-1
9.2 Input/Output Operations In C ..................................................................... 9-1
9.3 Other Include Files ......................................................................................... 9-2
9.4 Back To The File Named Simpleio.c ............................................................. 9-2
9.5 Dos Is Helping Us Out (Or Getting In The Way) ........................................ 9-2
9.6 Another Strange I/O Method ......................................................................... 9-3
9.7 Now We Need A Line Feed ............................................................................ 9-4
9.8 Which Method Is Best? .................................................................................. 9-4
9.9 Now To Read In Some Integers ..................................................................... 9-5
9.10 Character String Input ................................................................................ 9-6
9.11 Input/Output Programming In C ............................................................... 9-7
9.12 In Memory I/O .............................................................................................. 9-7
9.13 Is That Really Useful? .................................................................................. 9-8
9.14 Standard Error Output ................................................................................ 9-8
9.15 What About The Exit(4) Statement? .......................................................... 9-9
9.16 Programming Exercise ................................................................................. 9-9
10 File Input/Output ............................................................................... 10-1
10.1 Output To A File ........................................................................................... 10-1
10.2 Opening A File .............................................................................................. 10-1
10.3 Outputting To The File ................................................................................ 10-2
10.4 Closing A File ................................................................................................ 10-2
10.5 Outputting A Single Character At A Time ................................................ 10-2
10.6 The "Putc" Function .................................................................................... 10-3
10.7 Reading A File ............................................................................................... 10-3
10.8 Reading A Word At A Time ........................................................................ 10-4
10.9 This Is A Problem ......................................................................................... 10-4
10.10 Finally, We Read A Full Line .................................................................... 10-5
10.11 How To Use A Variable Filename ............................................................. 10-5
10.12 How Do We Print? ...................................................................................... 10-6
10.13 Programming Exercises ............................................................................. 10-7
11 Structures and Unions ....................................................................... 11-1
11.1 What Is A Structure? ................................................................................... 11-1
11.2 A Single Compound Variable ...................................................................... 11-1
11.3 Assigning Values To The Variables ............................................................ 11-2
11.4 How Do We Use The Resulting Data? ........................................................ 11-2
11.5 An Array Of Structures ............................................................................... 11-2
11.6 A Note To Pascal Programmers .................................................................. 11-3
11.7 We Finally Display All Of The Results ....................................................... 11-3
11.8 Using Pointers And Structures Together ................................................... 11-3
11.9 Pointer Arithmetic ........................................................................................ 11-4
11.10 Nested And Named Structures .................................................................. 11-4
11.11 Two More Variables ................................................................................... 11-5
11.12 Now To Use Some Of The Fields ............................................................... 11-5
11.13 More About Structures .............................................................................. 11-6
11.14 What Are Unions? ...................................................................................... 11-6
11.15 Another Union Example ............................................................................ 11-7
11.16 A New Concept, The Typedef .................................................................... 11-8
11.17 What Do We Have Now? ........................................................................... 11-9
11.18 Programming Exercises ............................................................................. 11-9
C Tutorial iii
12 Dynamic Allocation ............................................................................ 12-1
12.1 What Is Dynamic Allocation? ...................................................................... 12-1
12.2 Dynamic Variable Creation ......................................................................... 12-2
12.3 What Is A Heap? ........................................................................................... 12-2
12.4 More About Segments .................................................................................. 12-2
12.5 Back To The "Malloc" Function ................................................................. 12-3
12.6 What Is A Cast? ............................................................................................ 12-3
12.7 Using The Dynamically Allocated Memory Block ..................................... 12-3
12.8 Getting Rid Of The Dynamically Allocated Data ...................................... 12-4
12.9 That Was A Lot Of Discussion .................................................................... 12-4
12.10 An Array Of Pointers ................................................................................. 12-4
12.11 A Linked List .............................................................................................. 12-5
12.12 The Data Definitions ................................................................................... 12-6
12.13 The First Field ............................................................................................. 12-7
12.14 Filling Additional Structures ..................................................................... 12-7
12.15 Printing The Data Out ............................................................................... 12-7
12.16 More About Dynamic Allocation And Linked Lists ................................ 12-8
12.17 Another New Function - Calloc ................................................................. 12-8
12.18 Programming Exercises ............................................................................. 12-8
13 Character and Bit Manipulation ...................................................... 13-1
13.1 Upper And Lower Case ................................................................................ 13-1
13.2 Classification Of Characters ........................................................................ 13-2
13.3 The Logical Functions .................................................................................. 13-3
13.4 The Shift Instructions ................................................................................... 13-4
14Example Programs .............................................................................. 14-1
14.1 Why This Chapter? ...................................................................................... 14-1
14.2 whatnext.c - The Batch File Interrogator ............................................. 14-4
14.3 List.C - The Program Lister .................................................................... 14-6
14.4 Vc.C - The Visual Calculator ..................................................................... 14-9
15 The Visual Calculator - Version 1.00 ............................................... 15-1
15.1 The Visual Calculator Tutorial ................................................................... 15-1
15.2 Additional Comments ................................................................................... 15-3
16 Error Messages ................................................................................... 16-1
17 Coronado Enterprises C Tutor - Ver 1.00 ....................................... 17-1
18 HiTech C updates ............................................................................... 18-1
18.1 Relcc.c ............................................................................................................ 18-1
18.2 Modified Files ................................................................................................ 18-1
19 Further Reading ................................................................................. 19-1
19.1 Going from BASIC to C ............................................................................... 19-1
19.2 Programming in C, revised edition ............................................................. 19-1
19.3 Advanced C ................................................................................................... 19-1
19.4 ......................................................................................................................... 19-1
C Tutorial iv
Table of Figures
Trivial.c ........................................................................................................................ 2-1
Wrtsome.c .................................................................................................................... 2-1
Wrtmore.c ..................................................................................................................... 2-2
Oneint.c ........................................................................................................................ 2-2
Comments.c .................................................................................................................. 2-3
Goodform.c .................................................................................................................. 2-4
Uglyform.c ................................................................................................................... 2-5
While.c ......................................................................................................................... 3-1
Dowhile.c ..................................................................................................................... 3-1
Forloop.c ...................................................................................................................... 3-2
Ifelse.c .......................................................................................................................... 3-3
Breakcon.c .................................................................................................................... 3-3
Switch.c ........................................................................................................................ 3-4
Gotoex.c ....................................................................................................................... 3-5
Tempconv.c .................................................................................................................. 3-5
Dumbconv.c ................................................................................................................. 3-7
Intasign.c ...................................................................................................................... 4-1
Mortypes.c .................................................................................................................... 4-2
Lottypes.c ..................................................................................................................... 4-4
Compares.c ................................................................................................................... 4-6
Cryptic.c ....................................................................................................................... 4-9
Sumsqres.c .................................................................................................................... 5-1
Squares.c ...................................................................................................................... 5-3
Floatsq.c ....................................................................................................................... 5-4
Scope.c ......................................................................................................................... 5-5
Recurson.c .................................................................................................................... 5-8
Backward.c ................................................................................................................... 5-8
Define.c ........................................................................................................................ 6-1
Macro.c ......................................................................................................................... 6-2
Chrstrg.c ....................................................................................................................... 7-1
Strings.c ........................................................................................................................ 7-2
Intarray.c ...................................................................................................................... 7-3
Bigarray.c ..................................................................................................................... 7-4
Passback.c .................................................................................................................... 7-5
Multiary.c ..................................................................................................................... 7-6
Pointer.c ........................................................................................................................ 8-1
pointer2.c ...................................................................................................................... 8-3
twoway.c ...................................................................................................................... 8-5
simpleio.c ..................................................................................................................... 9-1
singleio.c ...................................................................................................................... 9-3
betterin.c ....................................................................................................................... 9-4
intin.c ............................................................................................................................ 9-5
stringin.c ....................................................................................................................... 9-6
special.c ........................................................................................................................ 9-8
formout.c ...................................................................................................................... 10-1
charout.c ....................................................................................................................... 10-2
readchar.c ..................................................................................................................... 10-3
readtext.c ...................................................................................................................... 10-4
readline.c ...................................................................................................................... 10-5
anyfile.c ........................................................................................................................ 10-6
printdat.c ....................................................................................................................... 10-6
struct1.c ........................................................................................................................ 11-1
struct2.c ........................................................................................................................ 11-2
C Tutorial v
struct3.c ........................................................................................................................ 11-3
nested.c ......................................................................................................................... 11-5
union1.c ........................................................................................................................ 11-7
union2.c ........................................................................................................................ 11-8
dynlist.c ........................................................................................................................ 12-1
bigdyn1.c ...................................................................................................................... 12-5
dynlink.c ....................................................................................................................... 12-6
uplow.c ......................................................................................................................... 13-1
charclas.c ...................................................................................................................... 13-2
bitops.c ......................................................................................................................... 13-3
shifter.c ......................................................................................................................... 13-4
dosex_1616.c ................................................................................................................ 14-4
whatnext.c .................................................................................................................... 14-6
list.c .............................................................................................................................. 14-6
vc.c ............................................................................................................................... 14-15
C Tutorial vi
Welcome to CHRISCLEM INT'L INC. ENT is a brand that promote other enterprises, Publish your services or product to the wide world in a bit of seconds we Edit video, Produce Music, Design and host Website, Graphic Design, Online Radio Hype, we bring all kind of news to your update, fashion and entertainment, sports and many lot more. This the only site and company you can get your services or product and goods been promoted Around the Globe, watch us on TV
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment