Write a program that compares (at least) two text files.
- The files to compare shall be specified on the command line.
- The output should be per different line, on stdout.
- You are encouraged to make changes to the provided skeleton.
- You are expected to write additional tests to cover larger files and potential edge-cases.
main.c
with an examplemain()
function;include/
with some headers suggesting modules that you may want to implement insrc/
;tests/
with sample input files & expected output, divided into solution stages;run_tests.py
so you don't spend more time in the terminal than in your editor.Makefile
to build the project.
cd bld && make; cd ..
(or enter the commands separately)./run_tests.py 0
(where0
is the stage you're testing)- If your build is broken:
make clean
frombld/
- If your build is broken:
cd bld; mingw32-make.exe; cd ..
python.exe run_tests.py 0
(where0
is the stage you're testing)- If your build is broken:
mingw32-make.exe clean
frombld\
- If your build is broken:
You may want to add extra compiler options in CFLAGS
or specify
extra source and include directories in the makefile.
You are strongly encouraged to implement the program in increasing levels of functionality and sophistication.
The skeleton suggests the following stages:
Check files for strict equality. Meaning any difference is considered a negative, and no difference - a positive.
"Files are identical.
" or "Files are different.
"
Count the number of non-identical lines. For each line, compare only its counterpart (so don't take added or deleted lines into account).
"Files are identical.
", "1 line differs.
", or "15 lines differ.
"
Print the lines of each file that differ. If one file is longer than the other, also show the extra lines.
Left 3: hello
Right 3: hi
Right 4: there
Your own design and tests. This is what will be evaluated.