Back to Guide -- Index -- Chapter 1
Even though most exercises only need a single source file, it is a good practice to put each exercise within its own directory. A typical exercise contains the following parts.
To make the life easier, I have created a template at The Exercise Template.
And there is a shell script `init.sh' in its parent directory. We can use it to generate the directory
for the exercises. For exmaple:
$ ./init.sh ex3_puzzle
$ ls -1 ex3_puzzle/
CMakeLists.txt
GNUmakefile
ex3-puzzle.c
expected1.txt
expected2.txt
go.sh
input1.txt
input2.txt
We can make the program by GNUmakefile,
$ export prog=ex3_puzzle && make -f GNUmakefile
$ ./go.sh
Or make it by CMake,
$ cmake -B build
$ make -C build
$ ./go.sh
By default, go.sh will run two tests. For more test cases,
$ ./go.sh 1 10
Will run for 10 tests from input1.txt to input10.txt.
There is also an old version of the exercise template, and solutions to some of the exercises at Yet Another Template and Solutions.
Back to Introduction -- Index -- Chapter 1