Skip to content

Commit 728b735

Browse files
finish Annalyn's Infiltration
1 parent c7243a5 commit 728b735

File tree

15 files changed

+4423
-4
lines changed

15 files changed

+4423
-4
lines changed

c/hello-world/HELP.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# Help
2+
3+
## Running the tests
4+
5+
Get the first test compiling, linking and passing by following the [three rules of test-driven development][3-tdd-rules].
6+
7+
The included makefile can be used to create and run the tests using the `test` task.
8+
9+
```console
10+
$ make test
11+
```
12+
13+
Create just the functions you need to satisfy any compiler errors and get the test to fail.
14+
Then write just enough code to get the test to pass.
15+
Once you've done that, move onto the next test.
16+
17+
As you progress through the tests, take the time to refactor your implementation for readability and expressiveness and then go on to the next test.
18+
19+
Try to use standard C99 facilities in preference to writing your own low-level algorithms or facilities by hand.
20+
21+
## Checking for memory leaks
22+
23+
The makefile comes also with a build that checks some common mistakes regarding memory leaks and out of bound access to arrays.
24+
To run these checks, use the following at the command line:
25+
26+
```console
27+
$ make memcheck
28+
```
29+
30+
[3-tdd-rules]: https://blog.cleancoder.com/uncle-bob/2014/12/17/TheCyclesOfTDD.html
31+
32+
## Submitting your solution
33+
34+
You can submit your solution using the `exercism submit hello_world.c hello_world.h` command.
35+
This command will upload your solution to the Exercism website and print the solution page's URL.
36+
37+
It's possible to submit an incomplete solution which allows you to:
38+
39+
- See how others have completed the exercise
40+
- Request help from a mentor
41+
42+
## Need to get help?
43+
44+
If you'd like help solving the exercise, check the following pages:
45+
46+
- The [C track's documentation](https://exercism.org/docs/tracks/c)
47+
- The [C track's programming category on the forum](https://forum.exercism.org/c/programming/c)
48+
- [Exercism's programming category on the forum](https://forum.exercism.org/c/programming/5)
49+
- The [Frequently Asked Questions](https://exercism.org/docs/using/faqs)
50+
51+
Should those resources not suffice, you could submit your (incomplete) solution to request mentoring.
52+
53+
Make sure you have read the [C track-specific documentation][c-track] on the Exercism site.
54+
This covers the basic information on setting up the development environment expected by the exercises.
55+
56+
## Submitting Incomplete Solutions
57+
58+
If you are struggling with a particular exercise, it is possible to submit an incomplete solution so you can see how others have completed the exercise.
59+
60+
## Resources
61+
62+
To get help if having trouble, you can use the following resources:
63+
64+
- [StackOverflow][] can be used to search for your problem and see if it has been answered already. You can also ask and answer questions.
65+
- [CPPReference][] can be used to look up information on C concepts, operators, types, standard library functions and more.
66+
- [TutorialsPoint][] has similar content as CPPReference in its C programming section.
67+
- [The C Programming][K&R] book by K&R is the original source of the language and is still useful today.
68+
69+
[c-track]: https://exercism.org/docs/tracks/c
70+
[stackoverflow]: http://stackoverflow.com/questions/tagged/c
71+
[cppreference]: https://en.cppreference.com/w/c
72+
[tutorialspoint]: https://www.tutorialspoint.com/cprogramming/
73+
[K&R]: https://www.amazon.com/Programming-Language-2nd-Brian-Kernighan/dp/0131103628/

c/hello-world/README.md

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# Hello World
2+
3+
Welcome to Hello World on Exercism's C Track.
4+
If you need help running the tests or submitting your code, check out `HELP.md`.
5+
6+
## Instructions
7+
8+
The classical introductory exercise.
9+
Just say "Hello, World!".
10+
11+
["Hello, World!"][hello-world] is the traditional first program for beginning programming in a new language or environment.
12+
13+
The objectives are simple:
14+
15+
- Modify the provided code so that it produces the string "Hello, World!".
16+
- Run the test suite and make sure that it succeeds.
17+
- Submit your solution and check it at the website.
18+
19+
If everything goes well, you will be ready to fetch your first real exercise.
20+
21+
[hello-world]: https://en.wikipedia.org/wiki/%22Hello,_world!%22_program
22+
23+
## Source
24+
25+
### Created by
26+
27+
- @JacobMikkelsen
28+
29+
### Contributed to by
30+
31+
- @bcc32
32+
- @benkelaar
33+
- @gea-migration
34+
- @h-3-0
35+
- @kytrinyx
36+
- @patricksjackson
37+
- @QLaille
38+
- @RealBarrettBrown
39+
- @ryanplusplus
40+
- @siebenschlaefer
41+
- @wolf99
42+
43+
### Based on
44+
45+
This is an exercise to introduce users to using Exercism - https://en.wikipedia.org/wiki/%22Hello,_world!%22_program

c/hello-world/hello_world.c

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#include "hello_world.h"
2+
3+
// Define the function itself.
4+
const char *hello(void)
5+
{
6+
return "Goodbye, Mars!";
7+
}

c/hello-world/hello_world.h

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// This is called an include guard, which ensures that the header is only
2+
// included once. You could alternatively use '#pragma once'. See
3+
// https://en.wikipedia.org/wiki/Include_guard.
4+
#ifndef HELLO_WORLD_H
5+
#define HELLO_WORLD_H
6+
7+
// Declare the 'hello()' function, which takes no arguments and returns a
8+
// 'const char *', i.e. a pointer to a character (in this case the first
9+
// character in a string). The function itself is defined in the hello_world.c
10+
// source file. Ths function is called by the test case(s) in the test source
11+
// file test/test_hello_world.c.
12+
const char *hello(void);
13+
14+
#endif

c/hello-world/makefile

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
### If you wish to use extra libraries (math.h for instance),
2+
### add their flags here (-lm in our case) in the "LIBS" variable.
3+
4+
LIBS = -lm
5+
6+
###
7+
CFLAGS = -std=c99
8+
CFLAGS += -g
9+
CFLAGS += -Wall
10+
CFLAGS += -Wextra
11+
CFLAGS += -pedantic
12+
CFLAGS += -Werror
13+
CFLAGS += -Wmissing-declarations
14+
CFLAGS += -DUNITY_SUPPORT_64 -DUNITY_OUTPUT_COLOR
15+
16+
ASANFLAGS = -fsanitize=address
17+
ASANFLAGS += -fno-common
18+
ASANFLAGS += -fno-omit-frame-pointer
19+
20+
.PHONY: test
21+
test: tests.out
22+
@./tests.out
23+
24+
.PHONY: memcheck
25+
memcheck: ./*.c ./*.h
26+
@echo Compiling $@
27+
@$(CC) $(ASANFLAGS) $(CFLAGS) test-framework/unity.c ./*.c -o memcheck.out $(LIBS)
28+
@./memcheck.out
29+
@echo "Memory check passed"
30+
31+
.PHONY: clean
32+
clean:
33+
rm -rf *.o *.out *.out.dSYM
34+
35+
tests.out: ./*.c ./*.h
36+
@echo Compiling $@
37+
@$(CC) $(CFLAGS) test-framework/unity.c ./*.c -o tests.out $(LIBS)

0 commit comments

Comments
 (0)