Project #2: A Stroll Down Memory Lane

Submit: Turn in your reverse.c source file using the turnin command on morbius.mscsnet.mu.edu or one of the other Systems Lab machines.

Work is to be completed individually. Be certain to include your name in the file. You may submit multiple times, but only the last turnin will be kept. The automatic submission system will not accept work after the deadline. (See turnin instructional video HERE. Note that the video is for a different course number, and that Morbius's domain name has changed since the video was made: morbius.mscs.mu.edu -> morbius.mscsnet.mu.edu)

Include a comment block at the very top of each file that contains the following:

/**
 * COSC 3250 - Project #
 * Explain briefly the functionality of the program.
 * @author [your name]
 * Instructor [your instructor]
 * TA-BOT:MAILTO [your email address]
 */

A Stunning Reversal

The Program

Write a C program that reads in an arbitrarily long sequence of positive integers, and outputs that same sequence in reverse order.

Your program should understand positive integers in binary (starting with "0b",) octal, decimal, and hexadecimal, but all output will be in decimal (base-10). This should reuse code from your calculator project.

Your program should ignore any amount of white space between integers, including tabs, spaces, newlines, etc. See the isspace() function in your text or in the man pages for details. Your output, however, should consist entirely of base-10 representation integers in a line by themselves.

In order to store an arbitrary list of integers, your program will need to request more memory from the operating system when the space it already has runs out. This kind of dynamic allocation is performed using the malloc() function, as detailed in your text and in the man pages. You may assume that we will test your program with at least 100,000,000 integers. Your program should exit gracefully if a malloc() request is denied.

The professor has provided an example program for your reference, executable on Morbius as ~brylow/os/Projects/reverse. In addition, there is a test generator executable as ~brylow/os/Projects/billionrandom. The test generator takes a single command-line parameter for the number of integers desired, and then outputs a predictable sequence of pseudo-random numbers [Wikipedia] using a linear congruential generator [Wikipedia] and rotating through the various bases.

Notes


[back]

[Revised 2020 Sep 01 11:36 DWB]