Pointers Gone Wild
In CS 125, CS 225, and other classes, you have used various languages that are considered to be “C based”, but up to now you may have very limited experience in C programming. This MP will provide a short programming introduction to pointers, strings, and functions in C.
This machine problem will be divided up into two pieces. In the first piece, you will be modifying functions originally with errors such that the outputs match the given output. In the second piece, you will need to write some code to call some ‘creatively defined’ functions so that those functions produce the desired output.
For this MP, you may modify:
All other files will be replaced with new/different files for grading. If you modify any other files for debugging purposes, please ensure you test your program with the original file.
There are erroneous/unimplemented functions in part1-functions.c. Your task is to modify functions according to comment above each function such that the output of part1 looks exactly as follows:
We have pre-uploaded some files to your mp0 svn directory, including part2-functions.c. Inside part2-functions.c, you will see twelve different functions, including first_step() (re-printed below).
To complete Part 2, you must complete the program part2-main.c so that part2-main.c makes calls to all twelve functions in part2-functions.c such that they print their “Illinois” line. When running ./part2, your output should look exactly like:
You should NOT edit the part2-functions.c file. In fact, when we grade your program, we will replace the part2-functions.c file with a new version of the file (and we’ll change the “Illinois” string so printing out “Illinois” in a for-loop will get you no credit).
Compile and Run
To compile the release version of the code run:
This will compile your code with some optimizations enabled, and will not include debugging information (if you use a debugger on the ‘release’ build, it will not be able to show you the original source code, or line numbers). Optimizations sometimes expose some bugs in your code that would not show up when no optimizations are enabled, but since optimizations tend to reorder your code while compiling, an optimized version of your code is not optimal for debugging.
You probably don’t need to worry about the different build types very much for this assignment, but the distinction will become more important on future assignments.
To compile your code in debug mode, run
make debug instead of
To run Part 1:
To run Part 2:
Grading, Submission, and Other Details
Please fully read details on Academic Honesty. These are shared between all MPs in CS 241.
We will be using Subversion as our hand-in system this semester. Our grading system will checkout your most recent (pre-deadline) commit for grading. Therefore, to hand in your code, all you have to do is commit it to your Subversion repository.
To check out the provided code for
pointers_gone_wildfrom the class repository, go to your cs241 directory (the one you checked out for “know your tools”) and run:
If you run
ls you will now see a
pointers_gone_wild folder, where you can find this assignment! To commit your changes (send them to us) type:
Your repository directory can be viewed from a web browser from the following URL: https://subversion.ews.illinois.edu/svn/sp16-cs241/NETID/pointers_gone_wild where NETID is your University NetID. It is important to check that the files you expect to be graded are present and up to date in your svn copy.