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
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
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
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
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
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
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
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
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
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