CORONADO ENTERPRISES C TUTORIAL - Version 2.4 This documentation and the accompanying software, including all of the example C programs and text files, are protected under United States copyright law to protect them from unauthorized commercialization. This version of the tutorial is distributed under the shareware concept, which means you are not required to pay for it. You are permitted to copy the disks, and pass the copies on to a friend, provided that you do not modify any files or omit any files from the complete package, and you are in fact encouraged to pass on complete copies to friends. You are permitted to charge a small fee to cover the costs of duplication, but you are not permitted to charge anything for the software itself. If you find the tutorial helpful, you are encouraged to register with the author and to submit a small fee to help compensate him for his time and expense in writing it. We will provide you with a beautifully printed copy of this tutorial if you submit a full registration. See the READ.ME file on either diskette for additional details. Whether or not you send a registration fee, feel free to request a copy of the lastest list of available tutorials and a list of the authorized Public Domain libraries that distribute our full line of programming language tutorials. Gordon Dodrill - Nov 10, 1989 Copyright (c) 1988, 1989, Coronado Enterprises Coronado Enterprises 12501 Coronado Ave NE Albuquerque, New Mexico 87122 C TUTORIAL - TABLE OF CONTENTS Introduction Page I-1 Chapter 1 - Getting started Page 1-1 FIRSTEX.C The first example program 1-3 Chapter 2 - Program Structure Page 2-1 TRIVIAL.C The minimum program 2-1 WRTSOME.C Write some output 2-1 WRTMORE.C Write more output 2-2 ONEINT.C One integer variable 2-3 COMMENTS.C Comments in C 2-4 GOODFORM.C Good program style 2-5 UGLYFORM.C Bad program style 2-5 Chapter 3 - Program Control Page 3-1 WHILE.C The While loop 3-1 DOWHILE.C The Do-While loop 3-2 FORLOOP.C The For loop 3-2 IFELSE.C The If & If-Else construct 3-3 BREAKCON.C The Break & Continue 3-4 SWITCH.C The Switch construct 3-4 GOTOEX.C The Goto Statement 3-5 TEMPCONV.C The temperature conversion 3-6 DUMBCONV.C Poor program style 3-7 Chapter 4 - Assignment & Logical Compare Page 4-1 INTASIGN.C Integer assignments 4-1 MORTYPES.C More data types 4-2 LOTTYPES.C Lots of data types 4-4 COMBINE.C Combining different types 4-6 COMPARES.C Logical compares 4-7 CRYPTIC.C The cryptic constructs 4-11 Chapter 5 - Functions, variables, & prototyping Page 5-1 SUMSQRES.C First functions 5-1 SQUARES.C Return a value 5-3 FLOATSQ.C Floating returns 5-4 SCOPE.C Scope of variables 5-5 RECURSON.C Simple Recursion Program 5-9 BACKWARD.C Another Recursion Program 5-11 FLOATSQ2.C Floating returns with prototypes 5-12 Chapter 6 - Defines & Macros Page 6-1 DEFINE.C Defines 6-1 MACRO.C Macros 6-3 ENUM.C Enumerated type 6-3 Chapter 7 - Strings and Arrays Page 7-1 CHRSTRG.C Character Strings 7-1 STRINGS.C More Character strings 7-3 INTARRAY.C Integer Array 7-4 BIGARRAY.C Many Arrays 7-4 PASSBACK.C Getting data from Functions 7-5 MULTIARY.C Multidimensional arrays 7-6 Chapter 8 - Pointers Page 8-1 POINTER.C Simple Pointers 8-1 POINTER2.C More pointers 8-4 TWOWAY.C Twoway Function Data 8-6 FUNCPNT.C A pointer to a function 8-7 Chapter 9 - Standard Input/Output Page 9-1 SIMPLEIO.C Simplest standard I/O 9-1 SINGLEIO.C Single character I/O 9-4 BETTERIN.C Better form of single I/O 9-4 INTIN.C Integer input 9-6 STRINGIN.C String input 9-7 INMEM.C In memory I/O conversion 9-9 SPECIAL.C Standard error output 9-10 Chapter 10 - File Input/Output Page 10-1 FORMOUT.C Formatted output 10-1 CHAROUT.C Single character output 10-3 READCHAR.C Read single characters 10-4 READTEXT.C Read single words 10-5 READGOOD.C Better read and display 10-6 READLINE.C Read a full line 10-6 ANYFILE.C Read in any file 10-6 PRINTDAT.C Output to the printer 10-7 Chapter 11 - Structures Page 11-1 STRUCT1.C Minimum structure example 11-1 STRUCT2.C Array of structures 11-2 STRUCT3.C Structures with pointers 11-3 NESTED.C Nested structure 11-5 UNION1.C An example union 11-7 UNION2.C Another Union example 11-8 BITFIELD.C Bitfield example 11-10 Chapter 12 - Dynamic Allocation Page 12-1 DYNLIST.C Simple Dynamic Allocation 12-1 BIGDYNL.C Large Dynamic Allocation 12-5 DYNLINK.C Dynamic Linked List Program 12-6 Chapter 13 - Character and Bit Manipulation Page 13-1 UPLOW.C Upper/Lower Case Text 13-1 CHARCLAS.C Character Classification 13-1 BITOPS.C Logical Bit Operations 13-2 SHIFTER.C Bit Shifting Operations 13-3 Chapter 14 - Example programs Page 14-1 DOSEX.C DOS call examples 14-2 WHATNEXT.C Ask Question in Batch File 14-3 LIST.C Source Code Lister 14-4 VC.C Visual Calculator 14-5 ABOUT THE AUTHOR ___________________________________________________________ The author of this tutorial began programming in 1961 using FORTRAN on an IBM 1620. Since then, most of his career has been involved with designing digital logic for satellite application. In 1983, being somewhat burned out with logic design, he began a study of some of the more modern programming languages and has since made a complete career shift to software development. After learning Pascal, C was studied, followed by Modula-2 and Ada, and more recently C++. Rather than simply learning the syntax of each new language, modern methods of software engineering were studied and applied to effectively utilize the languages. He is currently employed by a large research and development laboratory where he continues to study, teach, and apply the newer programming languages.