ADVANCED C PROGRAMMING – GTPL10

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.

^^

Duration

5 days

^^

Target Audience

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.

^^

Course Prerequisites

Students should have at least six months of C programming experience. These skills are also taught in the following course:

If you have any questions or doubts as to whether you meet the pre-requisites for this course, or indeed are wondering which course best suits you, please consult with us to discuss your suitability for course attendance.

^^

Suggested Follow on Courses

Please contact us for further details.

^^

Course Content

Chapter 1: A Review of C

Data Types

Operators

Control Flow Constructs – if

Loops

switch

Derived Data Types

Arrays

Array vs. Pointer

Arrays and Pointers

Structures

Header File for a Structure

Use of Structures

Structure References

Structure Assignments

Unions

Bitfields

Enumerations

 

Chapter 2: Functions

Function Fundamentals

Function Prototypes

Function Invocation and Definition

Subprogram Examples

Functions Returning a Value

Return Value Considerations

Recursive Functions

Evaluation of Function Arguments

Variable Number of Arguments

Scope of Variables

Storage Class Attributes

Initialization

 

Chapter 3: Bit Manipulation

Characteristics of Bitwise Problems

Defining the Problem Space

Bitwise Operators

Readability Aids

Assigning Bit Values

Writing Bitwise Functions

Circular Shifts

Character Information Array

Direct Lookup

Mapping With Bits

Radix Sort

 

Chapter 4: Pointers

Common Pointer Constructions

Pointer Arithmetic

Binary Search

Command Line Arguments

The Environment Pointer

Changing a Pointer through a Function Call

Processing Arrays With Pointers

Simulation Example

Simulating Higher Dimensional Arrays

Two Dimensional Arrays

Complex Declarations

Pointers to Functions

Surrogate Sorting: A Pointer Application

Sorting with Large Records

 

Chapter 5: Designing Data Types: Structures

Steps in Creating Data Types

Rationale For a New Data Type

The File fraction.h

Operations on the Fraction Data Types

Implementation of the Functions

Example Program Using Fractions

Applications with Fractions

Set Notation Examples

Creating the Set Type

Set Representation Example

Set Representation

Set Function Implementations

A Program Which Uses The Set Data Type

 

Chapter 6: Data Structures

Potential List Elements

Lists – What Are They?

Problems With a List as an Array

Lists as Arrays

Benefits of Linking Elements

A List of Linked Elements

Defining the List Data Type

The List Data Type

Implementations of List Functions

A Simple Program With a List

Other Types of Lists

The Need for Other Kinds of Lists

Ordered Lists

The rand Function

Circular Lists

Circular List Code

Circular Lists Principles

Two Way Lists – Example

Two Way Lists

Two Way List – print, order

Two Way List – main

Structures for Networks

Networks

Hashing is Close to Direct Lookup

Hashing / Searching

The Hashing Algorithm

Hashing main Program

Example Code For Linear Collision

Linear Collision Handling

The chain.h File

Chaining Collision Handling

Chaining – lookup Function

Chaining Code – main

Stacks

Stack Representation

Solving Problems With Stacks

Picture of the Stack

Push and Pop Functions

The Calculator Driver Program

Queues

Queue Driver Program

Binary Trees

Traversing Trees

tree.h

Left-Root-Right Traversal

Tree Algorithms

 

Chapter 7: Optimization Techniques

Knowing When to Optimize

Where to Optimize

Examples of Macros

Macros

Knowing When to Initialize

Initialization

Modifying the Data Structure – Example

Caching – Ready Access

Invariant Expressions

Logical Inefficiencies

Odds and Ends Examples

Odds and Ends

 

Chapter 8: Portability

Different Kinds of Portability

Source Code Portability

Prototype Problems

Portability with Functions

Problems with ints

Arithmetic Data Types

Problems with Bits

Bit Manipulation

Portable Masks

Pointer Problems

ANSI vs. Non-ANSI Examples

ANSI vs Non-ANSI

Odds and Ends Examples

Odds and Ends

 

Also Discussed:

Software Tools

The cc Command

Different C Compilers

Options – Examples

Compiler Options

Conditional Compile Examples

Conditional Compilation

Positing Assertions

The assert Macro

Libraries

Header File Support

Libraries

Graphics Coordinates

A Graphics Example

Examples of the Need for make

The make Command

An Example Makefile

The make Dependency Tree

SCCS Example

Source Code Control System

After a Revision Cycle

Source Code Control System

Library Functions

Building Command Strings

system

exit and atexit Examples

exit and atexit

signal

Using strtok

strtok

memcpy and memset

memcpy – memset

Using qsort

quicksort

Binary Search Example

bsearch

strstr Example

strstr

strchr Example

strchr, strrchr

Data Validation Example

strspn, strcspn

 

File Access

I/O From Applications Programs

System Calls vs. Library Calls

The fopen Function

Opening Disk Files

Table of Access Modes

Access Modes

Reasons for an fopen Failure

Errors In Opening Files

Example: Copying a File

I/O Library Calls

Character vs Line Examples

Character Input vs Line Input

Interpreting Input

Motivation for the scanf Function

scanf Examples

scanf

sscanf Example

scanf Variants

fscanf and scanf Example

scanf Variants

sprintf and fprintf Examples

printf Variants

An fclose Example

Closing Files – fclose

Error Examples

Servicing Errors – errno

Servicing Errors – Example

Servicing Errors – errno.h

Application for Binary I/O

Binary I/O

The main Function – Code

The main Function

create_db Function – fwrite

fwrite

print_db Function – fread

fread

retrieve_db Function

fseek

fflush and ftell Example

fflush and ftell

^^

See more Programming Languages courses