Week 08 Laboratory Exercises

Objectives

  • learning how to access files
  • learning how to work with binary data
  • learning how to use lseek

Preparation

Before the lab you should re-read the relevant lecture slides and their accompanying examples.

Getting Started

Set up for the lab by creating a new directory called lab08 and changing to this directory.
mkdir lab08
cd lab08

There are some provided files for this lab which you can fetch with this command:

1521 fetch lab08

If you're not working at CSE, you can download the provided files as a zip file or a tar file.

Exercise — individual:
Create a File of Integers

INTERNAL ERROR MISSING SOURCE FILE: activities/create_integers_file/index.html

When you think your program is working, you can use autotest to run some simple automated tests:

1521 autotest create_integers_file 

When you are finished working on this exercise, you must submit your work by running give:

give cs1521 lab08_create_integers_file create_integers_file.c

You must run give before Monday 04 November 12:00 (midday) (2024-11-04 12:00:00) to obtain the marks for this lab exercise. Note that this is an individual exercise, the work you submit with give must be entirely your own.

Exercise — individual:
Print the Bytes of A File

INTERNAL ERROR MISSING SOURCE FILE: activities/print_bytes/index.html

When you think your program is working, you can use autotest to run some simple automated tests:

1521 autotest print_bytes 

When you are finished working on this exercise, you must submit your work by running give:

give cs1521 lab08_print_bytes print_bytes.c

You must run give before Monday 04 November 12:00 (midday) (2024-11-04 12:00:00) to obtain the marks for this lab exercise. Note that this is an individual exercise, the work you submit with give must be entirely your own.

Exercise — individual:
Create a Binary File

INTERNAL ERROR MISSING SOURCE FILE: activities/create_binary_file/index.html

When you think your program is working, you can use autotest to run some simple automated tests:

1521 autotest create_binary_file 

When you are finished working on this exercise, you must submit your work by running give:

give cs1521 lab08_create_binary_file create_binary_file.c

You must run give before Monday 04 November 12:00 (midday) (2024-11-04 12:00:00) to obtain the marks for this lab exercise. Note that this is an individual exercise, the work you submit with give must be entirely your own.

Exercise — individual:
Read a file of little-endian integers

INTERNAL ERROR MISSING SOURCE FILE: activities/read_lit_file/index.html

When you think your program is working, you can use autotest to run some simple automated tests:

1521 autotest read_lit_file 

When you are finished working on this exercise, you must submit your work by running give:

give cs1521 lab08_read_lit_file read_lit_file.c

You must run give before Monday 04 November 12:00 (midday) (2024-11-04 12:00:00) to obtain the marks for this lab exercise. Note that this is an individual exercise, the work you submit with give must be entirely your own.

Exercise — individual:
Print File Modes

INTERNAL ERROR MISSING SOURCE FILE: activities/file_modes/index.html

When you think your program is working, you can use autotest to run some simple automated tests:

1521 autotest file_modes 

When you are finished working on this exercise, you must submit your work by running give:

give cs1521 lab08_file_modes file_modes.c

You must run give before Monday 04 November 12:00 (midday) (2024-11-04 12:00:00) to obtain the marks for this lab exercise. Note that this is an individual exercise, the work you submit with give must be entirely your own.

Challenge Exercise — individual:
Extract ASCII from a Binary File

INTERNAL ERROR MISSING SOURCE FILE: activities/hidden_strings/index.html

When you think your program is working, you can use autotest to run some simple automated tests:

1521 autotest hidden_strings 

When you are finished working on this exercise, you must submit your work by running give:

give cs1521 lab08_hidden_strings hidden_strings.c

You must run give before Monday 04 November 12:00 (midday) (2024-11-04 12:00:00) to obtain the marks for this lab exercise. Note that this is an individual exercise, the work you submit with give must be entirely your own.

Challenge Exercise — individual:
Print The Last line of Huge Files

INTERNAL ERROR MISSING SOURCE FILE: activities/last_line/index.html

When you think your program is working, you can use autotest to run some simple automated tests:

1521 autotest last_line 

When you are finished working on this exercise, you must submit your work by running give:

give cs1521 lab08_last_line last_line.c

You must run give before Monday 04 November 12:00 (midday) (2024-11-04 12:00:00) to obtain the marks for this lab exercise. Note that this is an individual exercise, the work you submit with give must be entirely your own.

Submission

When you are finished each exercises make sure you submit your work by running give.

You can run give multiple times. Only your last submission will be marked.

Don't submit any exercises you haven't attempted.

If you are working at home, you may find it more convenient to upload your work via give's web interface.

Remember you have until Week 9 Monday 12:00:00 (midday) to submit your work without receiving a late penalty.

You cannot obtain marks by e-mailing your code to tutors or lecturers.

You check the files you have submitted here.

Automarking will be run by the lecturer several days after the submission deadline, using test cases different to those autotest runs for you. (Hint: do your own testing as well as running autotest.)

After automarking is run by the lecturer you can view your results here. The resulting mark will also be available via give's web interface.

Lab Marks

When all components of a lab are automarked you should be able to view the the marks via give's web interface or by running this command on a CSE machine:

1521 classrun -sturec