Best代写-最专业靠谱代写IT | CS | 留学生作业 | 编程代写Java | Python |C/C++ | PHP | Matlab | Assignment Project Homework代写

C语言代写 | COMPUTING SCIENCE 201 Lab Exercise 6

C语言代写 | COMPUTING SCIENCE 201 Lab Exercise 6


COMPUTING SCIENCE 201 – Practical programming methodology Lab Exercise 6 – Special topics in C

Due: as indicated on Blackboard
Weight: 2.5% of the final mark
Type: Electronic submit your files using eSubmit Work: Individual


  • To extend your experience with C structures
  • To become familiar using low level and input/output operations in C


  • Properly acknowledge (add a note and/or hyperlink and/or comment) any help or resource you used.
  • Programs without ID boxes will have marks deducted


    Create a new directory named lab6. Within this directory do the following exercises:

    1) For this exercise, you will write a couple of compare functions to use with qsort on an array (of struct game).
    You will use the following structure:

    typedef struct {
        double price;
        char title[60];
    } game;

    In a file named lab6Eexercise1.c write the comparison functions compGamesByTitle(void *a, void * b) and compGamesByPrice(void *a, void * b) and main().

    The two compare functions will allow qsort to sort a non‐dynamic array with elements of type game by ascending alphabetical order of the title field, and respectively by ascending order of the price field.

    Your main function should make an array of at 7 game elements as indicated, and then print it out after each call to qsort with a compare function to demonstrate that it is working.

Position Price

  1. 1  22.79
  2. 2  0.01
  3. 3  7.79
  4. 4  14.99
  5. 5  0
  6. 6  7.79
  7. 7  64.96

Opus Magnum Minecraft
Code Combat Lemmings Revolution Warcraft

2) In the game of ginp-gonp players play rounds which are won or lost. There are no ties. The first player to win 15 rounds wins the game.; thus, the score of a game of ginp-gonp can vary from 15:0 to 0:15.
Write a module named lab6Exercise2 (you will need both a .h and .c file) in which:

  • Create a representation of ginp-gonp scores which uses only 1 byte;
  • Write a function named printGG which prints a score in your representation in the format A:B – where A

    is the number of rounds won by the first player and B is the number of rounds won by the second player;

  • Write a function named writeGG which writes a ginp-gonp score in your representation into a binary file

specified by its name; if the file exists it will be overwritten.

  • Write a function readGG which reads a ginp-gonp score in your representation from a binary file specified by its name, then call printGG to print it. If there are several scores in the file, your function must read the last score.
  • Write a main function in the file main.c which sets a score to 10:1, calls printGG, then writeGG, then readGG.
    3) lab6Exercise3.c

    “A hash function is any function that can be used to map data of arbitrary size to data of a fixed size. … A cryptographic hash function allows one to easily verify that some input data maps to a given hash value, but if the input data is unknown, it is deliberately difficult to reconstruct it (or any equivalent alternatives) by knowing the stored hash value. This is used for assuring integrity of transmitted data.” [Wikipedia]

    For this exercise you will extend the purpose of a cryptographic hash by including a timestamp, trying to certify the content of a file at a given time.
    You will use the OpenSSl evp library (only the message digest related functions). Here you can find the man pages for the EVP Message Digest functions. This link is an example of using EVP Message Digest library.

    For the question you must write a program which takes the name of a file as a command line argument and then produces the SHA256 digest of the content of the file concatenated with the current timestamp (in seconds). Run the program on a sample text file. Copy the results of the run and a cat of the text file from the terminal into a text file named lab6Exercise3.txt.


    • You may want to research the time function
    • Once a message digest context is created you can use EVP_DigestUpdate() to add more data to be



      Create a new tarball of your directory named lab6.tar.gz that contains the files: lab6Exercise1.c

      Marks will be deducted for any .o files or executables in your submission. All submissions should be through eSubmit.

      If files are not named as specified, you risk receiving a mark of zero.

      To avoid receiving a zero on this exercise, check the following on eSubmit:

  • you got full marks, if not check your tar file, file names, and your code.
  • all cats are successful, i.e. show file content, if not check your file names

    Items: Mark

    Correct submission 1 Exercise 1 5 Exercise 2 6 Exercise 3 6 TOTAL 18