Get new post automatically.

Enter your email address:


C Programming Tutorial

Table of Contents
  • C Programming Tutorial
  • Preface
  • Introduction
    • High Levels and Low Levels
    • Basic ideas about C
    • The Compiler
    • Errors
    • Use of Upper and Lower Case
    • Declarations
    • Questions
  • Reserved words and an example
    • The printf() function
    • Example Listing
    • Output
    • Questions
  • Operating systems and environments
    • Files and Devices
    • Filenames
    • Command Languages and Consoles
    • Questions
  • Libraries
    • Questions
  • Programming style
  • The form of a C program
    • Questions
  • Comments
    • Example 1
    • Example 2
    • Question
  • Functions
    • Structure diagram
    • Program Listing
    • Functions with values
    • Breaking out early
    • The exit() function
    • Functions and Types
    • Questions
  • Variables, Types and Declarations
    • Declarations
    • Where to declare things
    • Declarations and Initialization
    • Individual Types
      • char
      • Listing
      • Integers
    • Whole numbers
      • Floating Point
    • Choosing Variables
    • Assigning variables to one another
    • Types and The Cast Operator
    • Storage class static and extern
    • Functions, Types and Declarations
    • Questions
  • Parameters and Functions
    • Declaring Parameters
    • Value Parameters
    • Functions as actual parameters
    • Example Listing
    • Example Listing
    • Variable Parameters
    • Example Listing
    • Questions
  • Scope : Local And Global
    • Global Variables
    • Local Variables
    • Communication : parameters
    • Example Listing
    • Style Note
    • Scope and Style
    • Questions
  • Preprocessor Commands
    • Macro Functions
    • When and when not to use macros with parameters
    • Example Listing
    • Note about #include
    • Other Preprocessor commands
    • Example
    • Questions
  • Pointers
    • & and *
    • Uses for Pointers
    • Pointers and Initialization
    • Example Listing
    • Types, Casts and Pointers
    • Pointers to functions
    • Calling a function by pointer
    • Questions
  • Standard Output and Standard Input
    • printf
    • Example Listing
    • Output
    • Formatting with printf
    • Example Listing
    • Output
    • Special Control Characters
    • Questions
    • scanf
    • Conversion characters
    • How does scanf see the input?
    • First account of scanf
    • The dangerous function
    • Keeping scanf under control
    • Examples
    • Matching without assigning
    • Formal Definition of scanf
    • Summary of points about scanf
    • Questions
    • Low Level Input/Output
      • getchar and putchar
      • gets and puts
    • Questions
  • Assignments, Expressions and Operators
    • Expressions and values
    • Example
    • Output
    • Parentheses and Priority
    • Unary Operator Precedence
    • Special Assignment Operators ++ and --
    • More Special Assignments
    • Example Listing
    • Output
    • The Cast Operator
    • Expressions and Types
    • Comparisons and Logic
    • Summary of Operators and Precedence
    • Questions
  • Decisions
    • if
    • Example Listings
    • if ... else
    • Nested ifs and logic
    • Example Listing
    • Stringing together if..else
    • switch: integers and characters
    • Example Listing
    • Things to try
  • Loops
    • while
    • Example Listing
    • Example Listing
    • do..while
    • Example Listing
    • for
    • Example Listing
    • The flexible for loop
    • Quitting Loops and Hurrying Them Up!
    • Nested Loops
    • Questions
  • Arrays
    • Why use arrays?
    • Limits and The Dimension of an array
    • Arrays and for loops
    • Example Listing
    • Arrays Of More Than One Dimension
    • Arrays and Nested Loops
    • Example Listing
    • Output of Game of Life
    • Initializing Arrays
    • Arrays and Pointers
    • Arrays as Parameters
    • Questions
  • Strings
    • Conventions and Declarations
    • Strings, Arrays and Pointers
    • Arrays of Strings
    • Example Listing
    • Strings from the user
    • Handling strings
    • Example Listing
    • String Input/Output
      • gets()
      • puts()
      • sprintf()
      • sscanf()
    • Example Listing
    • Questions
  • Putting together a program
    • The argument vector
    • Processing options
    • Environment variables
  • Special Library Functions and Macros
    • Character Identification
    • Examples
    • Program Output
    • String Manipulation
    • Examples
    • Mathematical Functions
    • Examples
    • Maths Errors
    • Example
    • Questions
  • Hidden operators and values
    • Extended and Hidden =
    • Example
    • Hidden ++ and --
    • Arrays, Strings and Hidden Operators
    • Example
    • Cautions about Style
    • Example
    • Questions
  • More on data types
    • Special Constant Expressions
    • FILE
    • enum
    • Example
    • Example
    • Suggested uses for enum
    • void
    • volatile
    • const
    • struct
    • union
    • typedef
    • Questions
  • Machine Level Operations
    • Bit Patterns
    • Flags, Registers and Messages
    • Bit Operators and Assignments
    • The Meaning of Bit Operators
    • Shift Operations
    • Truth Tables and Masking
      • Complement ~
      • AND &
      • OR |
      • XOR/EOR ^
    • Example
    • Output
    • Example
    • Example
    • Questions
  • Files and Devices
    • Files Generally
    • File Positions
    • High Level File Handling Functions
    • Opening files
    • Closing a file
    • fprintf()
    • fscanf()
    • skipfilegarb() ?
    • Single Character I/O
    • getc() and fgetc()
    • ungetc()
    • putc() and fputc()
    • fgets() and fputs()
    • feof()
    • Printer Output
    • Example
    • Output
    • Converting the example
    • Filing Errors
    • Other Facilities for High Level Files
    • fread() and fwrite()
    • File Positions: ftell() and fseek()
    • rewind()
    • fflush()
    • Low Level Filing Operations
    • File descriptors
    • open()
    • close()
    • creat()
    • read()
    • write()
    • lseek()
    • unlink() and remove()
    • Example
    • Questions
  • Structures and Unions
    • Organization: Black Box Data
    • struct
    • Declarations
    • Scope
    • Using Structures
    • Arrays of Structures
    • Example
    • Structures of Structures
    • Pointers to Structures
    • Example
    • Pre-initializing Static Structures
    • Creating Memory for Dynamical struct Types
    • Unions
      • Declaration
      • Using unions
    • Questions
  • Data Structures
    • Data Structure Diagrams
    • The Tools: Structures, Pointers and Dynamic Memory
    • Programme For Building Data Structures
    • Setting Up A Data Structure
    • Example Structures
    • Questions
  • Recursion
    • Functions and The Stack
    • Levels and Wells
    • Tame Recursion and Self-Similarity
    • Simple Example without a Data Structure
    • Simple Example With a Data Structure
    • Advantages and Disadvantages of Recursion
    • Recursion and Global Variables
    • Questions
  • Example Programs
    • Statistical Data Handler
      • The Editor
      • Insert/Overwrite
      • Quitting Sections
      • The Program Listing
    • Listing
    • Variable Cross Referencer
      • Listing Cref.c
      • Output of Cross Referencer
      • Comments
  • Errors and debugging
    • Compiler Trappable Errors
      • Missing semicolon;
      • Missing closing brace }
      • Mistyping Upper/Lower Case
      • Missing quote "
      • Variable not declared or scope wrong
      • Using a function or assignment inside a macro
      • Forgetting to declare a function which is not type int
      • Type mismatch in expressions
    • Errors not trappable by a compiler (run time errors)
      • Confusion of = and ==
      • Missing & in scanf
      • Confusing C++ and ++C
      • Unwarranted assumptions about storage
      • The number of actual and formal parameters does not match
      • The conversion string in scanf/printf is wrong
      • Accidental confusion of int, short and char
      • Arrays out of bounds
      • Mathematical Error
      • Uncoordinated Output using buffered I/O
      • Global Variables and Recursion
    • Tracing Errors
      • Locating a problem
    • Pathological Problems
    • Porting Programs between computers
    • Questions
  • Summary of C
    • Reserved Words
    • Preprocessor Directives
    • Header Files and Libraries
    • Constants
    • Primitive Data Types
    • Storage Classes
    • Identifiers
    • Statements
    • Character Utilities
    • Special Control Characters
    • Input/Output Functions
    • printf conversion specifiers
    • scanf conversion specifers
    • Maths Library
    • goto
  • All the Reserved Words
  • Three Languages: Words and Symbols Compared
  • Character Conversion Table
  • Emacs style file
  • Answers to questions