Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Start by getting the files. Type 2 6 4 get hw 0 5 and then cd hw 0 5 from bash. You will find only

Start by getting the files. Type 264get hw05 and then cd hw05 from bash.
You will find only one file: mintf.h. That is the header file. It defines the signature of two of the functions you will implement: mintf(...) and print_integer(...).
You will be creating three new files: mintf.c, test_mintf.c, and test_mintf.txt. There is no starter code (other than the header file).
mintf.c is where your mintf(...) and print_integer(...) implementations will go. Copy your print_integer(...) from HW02 into it. Copy the function signature for mintf(...) from mintf.h into mintf.c. Make sure all of the following headers are included at the top of your mintf.c.(Type these manually into your file.)
#include
#include
#include
#include "mintf.h"
test_mintf.c will contain a main(...) function that will test your mintf(...) and print_integer(...). It must exercise all of the functionality in those two functions. For this homework, that means that in the course of running your test_mintf.c file, every line of code in your mintf.c should be executed at some point. To do this, you simply have several mintf(...) that include all of the format codes above, including a variety of valid values, including positive integers, negative integers, 0, strings, and an empty string. It should also have a few print_integer(...) statements to test that on its own. This will give you a very simple way to know for sure if your code works.
Use test-driven development to do this assignment incrementally.
test_mintf.txt will contain the expected output from running your tests in test_mintf.c. It will be a simple text file.
To test if your code works perfectly, you will run the following:
gcc test_mintf.c mintf.c -o test_mintf # compile your test together with your mintf.c to create an executable called test_mintf
./test_mintf > test_mintf.actual # run your executable and send the output to a file called test_mintf.actual (That filename is arbitrary.)
diff test_mintf.actual test_mintf.txt # compare the actual output with the expected output using the diff command
The diff command prints the differences so if you see any output at all, then your test failed. If you see no output, then it passed.
gcc test_mintf.c mintf.c -o test_mintf && ./test_mintf | diff test_mintf.txt -

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions