MP0: Baby-steps in C
Due: Wednesday, Sept. 4, 2013 at 11:59pm via svn
This MP consists of 19 functions, each containing one or more of the following problems:
The 19 functions are divided up into four files: part1.c, part2.c, part3.c, and part4.c.
Each function describes its purpose. You will need to edit the code in order to make sure the function achieves its written
- Syntax Error: These errors will prevent the code from compiling.
- Runtime Errors: These errors will cause the code to produce a segmentation fault (or other crash).
- Logical Errors: These errors will cause the code to produce the wrong output, even though it works.
- Missing Code: Related to logical errors, some code is simply missing and needs to be added.
- Memory Leak: Some code will leak memory after the program is finished using the memory it has allocated. Your program must be leak-free.
You will find the following files as part of this MP:
These files you are required to edit, and will be graded by the autograder:
- part1.c: Five functions for you to fix/complete.
- part2.c: Five functions for you to fix/complete.
- part3.c: Five functions for you to fix/complete.
- part4.c: Four functions for you to fix/complete.
You can modify these files by adding test cases, but these files will not be used by the autograder:
- main.c: The main() funciton of your program, used to call all 19 functions for grading.
You should not modify these files:
- soln.out: The output of a completed MP0 assignment, your output should match this file when your MP is complete.
- main.h: Header file for main.c, used to import the 19 functions into main.c.
- Makefile: Any changes to the Makefile will result in your code no longer working with the autograder.
The grading for MP0 follows the standard CS 241 MP Grading Policy.
For the execution (90%) of the MP grade, each of the 19 functions will carry equal weight.
Compiling and Running
To compile and run, use the following commands from a terminal on a Linux machine:
$ make clean
To check the output of the MP, run the following command:
$ ./mp0 >my.out
$ diff -s my.out soln.out
Your program's execution is correct if and only if the output of the diff program prints:
Files my.out and soln.out are identical
You will also need to run valgrind to ensure your program does not contain memory leaks or
illegal memory accesses. The full details are outlined in the CS 241 MP Grading Policy.
This "memory testing" is worth 10% of your overall grade.