Week 6 Tutorial

Census Date

The census date is this Thursday on the 31st August. If you drop the course before midnight (11:59pm) you will not incur financial penalty. If you are enrolled in the course after midnight on the evening of Thursday the 31st of August you will pay for the course.

If you feel that you are not keeping up with course content you may want to consider dropping the course. If you fall behind in this course you will require a lot of work to catch up in this course.

Consider your experience with Assignment 0 – if you were unable to complete the assignment, you may want to seriously consider whether you should continue being enrolled in the course this semester.

Structured Data

structs allow us to combine multiple variables and bundle them together. One example where we may want to do this is where we have values that have multiple components.

One example of values that have multiple components are points in 2D or 3D space.

typedef struct _point2d {
    double x;
    double y;
} point2d;

typedef struct _point3d {
    double x;
    double y;
    double z;
} point2d;

Another example is Complex Numbers. Complex numbers have a real and imaginary component. Mathematical operations on complex numbers work differently, due to how they are defined.

Walk through the complexAbs which implements the mathematical abs function for complex types.

BMP Images

We can represent images in many file formats. One common format that used to be popular was BMP.

For a computer to be able to display an image, it has to know the colour for each pixel in the image as well as other information about how the pixels are arranged.

The information about the image is called the metadata and contains information such as

The pixel colour information is stored as a 2-dimensional array in the file. Colour is represented as a mix of red, blue, and green light. Each pixel represents its colour by representing the amount of red, green, and blue light to use by specifying a value between 0 (no light) and 255 (maximum light) and uses a single byte for each value.

structs, like all other types, can be placed into arrays.

Walk through the pacman activity during your tutorial.

Simple Server

Computers can talk to each other over computer networks. One common way for computers to communicate with each other is through the World Wide Web. The web mostly uses a protocol called HTTP.

Walk through the simpleServer activity to create a web server in C that will serve a simple message to any web browser that connects to it.