Slideshow

Intro & Adv. : C Programming

E-mail

Intro to C Programming

This course provides students with a comprehensive study of the C programming language. Classroom lectures stress the strengths of C, which provide programmers with the means of writing efficient, maintainable, and portable code. The lectures are supplemented with non-trivial lab exercises.

Who Should Attend?

It's not required that you have any previous programming experience, although it's preferred.

Prerequisites

The student should have good mathematical skills.

Benefits of Attendance:

Upon completion of this course, students will be able to:

· Write C programs that are non-trivial.

· Use arrays as part of the software solution.

· Use the variety of data types appropriate to specific programming problems.

· Utilize pointers to efficiently solve problems.

· Include the structure data type as part of the solution.

· Utilize the modular features of the language.

· Create their own data types.

· Demonstrate efficiency and readability.

· Use functions from the portable C library.

· Demonstrate the use of the various control flow constructs.

Course Outline

· Getting Started

o What is C?

o Background

o Sample Program

o Components of a C Program

o Examples

o Data Types

o Variables

o Naming Conventions for C Variables

o Printing and Initializing Variables

o Array Examples

o Compiling and Executing a C Program

· Functions and Operators

o Examples of C Functions

o Functions

o sum Invoked from main

o Invoking Functions

o Elementary Operators

o The operator= Operators

o Operators

o The Conditional Operator

o Increment and Decrement Examples

o Increment and Decrement Operators

· Control Flow Constructs

o Examples of Expressions

o if

o if else

o while

o for

o Endless Loops

o do while

o break and continue

o switch

o else if

· The C Preprocessor

o #define

o Macros

o #include

o Conditional Compilation

o #ifdef

o #ifndef

· Simple I/O

o Character I/O

o End of File

o Simple I/O Examples

o Simple I/O Redirection

o I/O with Character Arrays

· More on Functions

o General

o Function Declarations

o Returning a Value or Not

o Function Prototypes

o Arguments and Parameters

o Organization of C Source Files

o Extended Example

o The getline Function

o The strcmp Function

o The check Function

o The atoi Function

o The average Function

o Summary

· Bit Manipulation

o Defining the Problem Space

o A Programming Example

o Bit Wise Operators

o Bit Manipulation Functions

o Circular Shifts

· Strings

o Fundamental Concepts

o Aggregate Operations

o String Functions

· Higher Dimensional Arrays

o Array Dimensions

o An Array as an Argument to a Function

o String Arrays

· Separate Compilation

o Compiling Over Several Files

o Function Scope

o File Scope

o Program Scope

o Local static

o register and extern

o Object Files

o Libraries

o The C Loader

o Header Files

· Pointers (Part 1)

o Fundamental Concepts

o Pointer Operators and Operations

o Changing an Argument with a Function Call

o Pointer Arithmetic

o Array Traversal

o String Functions with Pointers

o Pointer Difference

o Prototypes for String Parameters

o Relationship Between an Array and a Pointer

o The Pointer Notation *p++

· Pointers (Part 2)

o Dynamic Storage Allocation - malloc

o Functions Returning a Pointer

o Initialization of Pointers

o gets - a Function Returning a Pointer

o An Array of Character Pointers

o Two Dimensional Arrays vs. Array of Pointers

o Command Line Arguments

o Pointers to Pointers

o Practice with Pointers

o Function Pointers

· Structures

o Fundamental Concepts

o Describing a Structure

o Creating Structures

o Operations on Structures

o Functions Returning Structures

o Passing Structures to Functions

o Pointers to Structures

o Array of Structures

o Functions Returning a Pointer to a Structure

· Structure Related Items

o typedef - New Name for an Existing Type

o Bit Fields

o unions

o Non-Homogeneous Arrays

o Enumerations

· File I/O

o System Calls vs. Library Calls

o Opening Disk Files

o fopen

o I/O Library Functions

o Copying a File

o Character Input vs. Line Input

o scanf

o printf

o fclose

o Servicing Errors - errno.h

o feof

· Information About Files

o The stat Function

o File Existence

o Telling Time - time and ctime

o Telling Time – localtime

· I/O With Structures

o A Database Application

o The menu Function

o The fwrite Function

o The create_db Function

o The fread Function

o The print_db Function

o fseek

o The retrieve_db Function

o fflush and ftell

· Useful Library Functions

o strstr

o strchr, strrchr

o system

o strtok

o strspn, strcspn

o Math Functions

o Character Testing Functions

o exit and atexit

o signal

o memcpy and memset

o qsort

o Binary Search - bsearch

Advanced C Programming

Course Description

This course broadens the skills of a C language programmer by introducing sophisticated problem solving techniques including the advanced use of pointers, abstract data types, data structures, portability, and optimization techniques. Skills are reinforced by hands-on laboratory exercises.

Who Should Attend?

This course is for anybody who has been programming in C for at least six months or who is a skilled programmer and has taken a C introductory course.

Prerequisites

Students should have at least six months of C programming experience.

Benefits Of Attendance

1. Master the use of pointers in a wide variety of problems.

2. Use sophisticated pointer techniques to solve problems involving advanced data structures such as lists, stacks, queues and trees.•

3. Choose from a wide variety of data structures to implement the most efficient solution to a problem.

4. Apply the proper optimization technique to your C code.

5. Apply many portability techniques to your C code.

6. Use bit manipulation techniques for efficient solutions to problems.

7. Write programs which emphasize modern program design techniques which emphasize code reuse.

8. Write powerful C programs which make "calls" directly into the UNIX operating system through the use of system calls.

9. Decrease development time in writing applications through a more thorough understanding of sophisticated concepts in C.

Course Outline

· A Review of C

o Data Types

o Operators

o Control Flow Constructs - if

o Loops

o switch

o Derived Data Types

o Arrays

o Array vs. Pointer

o Arrays and Pointers

o Structures

o Header File for a Structure

o Use of Structures

o Structure References

o Structure Assignments

o Unions

o Bitfields

o Enumerations

· Functions

o Function Fundamentals

o Function Prototypes

o Function Invocation and Definition

o Subprogram Examples

o Functions Returning a Value

o Return Value Considerations

o Recursive Functions

o Evaluation of Function Arguments

o Variable Number of Arguments

o Scope of Variables

o Storage Class Attributes

o Initialization

· Bit Manipulation

o Characteristics of Bitwise Problems

o Defining the Problem Space

o Bitwise Operators

o Readability Aids

o Assigning Bit Values

o Writing Bitwise Functions

o Circular Shifts

o Character Information Array

o Direct Lookup

o Mapping With Bits

o Radix Sort

· Pointers

o Common Pointer Constructions

o Pointer Arithmetic

o Binary Search

o Command Line Arguments

o The Environment Pointer

o Changing a Pointer through a Function Call

o Processing Arrays With Pointers

o Simulation Example

o Simulating Higher Dimensional Arrays

o Two Dimensional Arrays

o Complex Declarations

o Pointers to Functions

o Surrogate Sorting: A Pointer Application

o Sorting with Large Records

· Designing Data Types:

o Structures

o Steps in Creating Data Types

o Rationale For a New Data Type

o The File fraction.h

o Operations on the Fraction Data Types

o Implementation of the Functions

o Example Program Using Fractions

o Applications with Fractions

o Set Notation Examples

o Creating the Set Type

o Set Representation Example

o Set Representation

o Set Function Implementations

o A Program Which Uses The Set Data Type

· Data Structures

o Potential List Elements

o Lists - What Are They?

o Problems With a List as an Array

o Lists as Arrays

o Benefits of Linking Elements

o A List of Linked Elements

o Defining the List Data Type

o The List Data Type

o Implementations of List Functions

o A Simple Program With a List

o Other Types of Lists

o The Need for Other Kinds of Lists

o Ordered Lists

o The rand Function

o Circular Lists

o Circular List Code

o Circular Lists Principles

o Two Way Lists - Example

o Two Way Lists

o Two Way List - print, order

o Two Way List - main

o Structures for Networks

o Networks

o Hashing is Close to Direct Lookup

o Hashing / Searching

o The Hashing Algorithm

o Hashing main Program

o Example Code For Linear Collision

o Linear Collision Handling

o The chain.h File

o Chaining Collision Handling

o Chaining - lookup Function

o Chaining Code - main

o Stacks

o Stack Representation

o Solving Problems With Stacks

o Picture of the Stack

o Push and Pop Functions

o The Calculator Driver Program

o Queues

o Queue Driver Program

o Binary Trees

o Traversing Trees

o tree.h

o Left-Root-Right Traversal

o Tree Algorithms

· Optimization Techniques

o Knowing When to Optimize

o Where to Optimize

o Examples of Macros

o Macros

o Knowing When to Initialize

o Initialization

o Modifying the Data Structure -Example

o Caching - Ready Access

o Invariant Expressions

o Logical Inefficiencies

o Odds and Ends Examples

o Odds and Ends

· Portability

o Different Kinds of Portability

o Source Code Portability

o Prototype Problems

o Portability with Functions

o Problems with ints

o Arithmetic Data Types

o Problems with Bits

o Bit Manipulation

o Portable Masks

o Pointer Problems

o ANSI vs. Non-ANSI Examples

o ANSI vs Non-ANSI

o Odds and Ends Examples

o Odds and Ends

· Software Tools

o The cc Command

o Different C Compilers

o Options - Examples

o Compiler Options

o Conditional Compile Examples

o Conditional Compilation

o Positing Assertions

o The assert Macro

o Libraries

o Header File Support

o Libraries

o Graphics Coordinates

o A Graphics Example

o Examples of the Need for make

o The make Command

o An Example Makefile

o The make Dependency Tree

o SCCS Example

o Source Code Control System

o After a Revision Cycle

o Source Code Control System

· Library

o Functions

o Building Command Strings

o system

o exit and atexit Examples

o exit and atexit

o signal

o Using strtok

o strtok

o memcpy and memset

o memcpy - memset

o Using qsort

o quicksort

o Binary Search Example

o bsearch

o strstr Example

o strstr

o strchr Example

o strchr, strrchr

o Data Validation Example

o strspn, strcspn

o Appendix C: File Access

o I/O From Applications Programs

o System Calls vs. Library Calls

o The fopen Function

o Opening Disk Files

o Table of Access Modes

o Access Modes

o Reasons for an fopen Failure

o Errors In Opening Files

o Example: Copying a File

o I/O Library Calls

o Character vs Line Examples

o Character Input vs Line Input

o Interpreting Input

o Motivation for the scanf Function

o scanf Examples

o scanf

o sscanf Example

o scanf Variants

o fscanf and scanf Example

o scanf Variants

o sprintf and fprintf - Examples

o printf Variants

o An fclose Example

o Closing Files - fclose

o Error Examples

o Servicing Errors - errno

o Servicing Errors - Example

o Servicing Errors - errno.h

o Application for Binary I/O

o Binary I/O

o The main Function - Code

o The main Function

o create_db Function - fwrite

o fwrite

o print_db Function - fread

o fread

o retrieve_db Function

o fseek

o fflush and ftell Example

o fflush and ftell

o Exercises

Share this page!