Exercism problems in C
Please see the Exercism contributing guide for general contribution tips.
All test and example code should be written using the Linux kernel coding style with 3 space indents and no tabs.
If GNU indent is installed, this can be run on all files by executing indent.sh.
To run it on a single file, you can execute:
indent -linux -i3 -nut $(file)If your system does not support the -linux option, you can run the long form command instead:
indent -nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 -d0 -di1 -nfc1 -i3 -nut -ip0 -l80 -lp -npcs -nprs -npsl -sai -saf -saw -ncs -nsc -sob -nfca -cp33 -ss -il1 $(file)See the GNU indent manual for more information.
Each exercise should be contained in a directory c/exercises/<my exercise> with <my exercise> referring to the name of the exercise. The structure of the directory is as follows:
+-- <my exercise>
+-- makefile
+-- src
| +-- example.c
| +-- example.h | <my exercise>.h
+-- test
+-- test_<my exercise>.c
+-- vendor
+-- unity.c
+-- unity.h
+-- unity_internals.h
-
test- contains the test filetest_<my exercise>.cand avendordirectory containing the test harness Unity from ThrowTheSwitch. ThrowTheSwitch has a decent guide on getting started with Unity should you desire a tutorial. -
src- contains the example filesexample.candexample.h. These are both skipped by theexercismcli when downloading to the client, so it is imperative that you do not reference the names of the files in your code. If you need to provide a header file example that is necessary to run your tests it should be named<my exercise>.hinstead. Please also useincludeguards in your header files. The tests can be run using thebin/run-testsscript which will rename theexample.{c|h}files accordingly.
The MIT License (MIT)
Copyright (c) 2014 Katrina Owen, _@kytrinyx.com