To start with, we need to compile our example. Following the above advice about compiler flags, we will use the following command line to compile it:
gcc -g ecount1.c -o ecount1
This will make the executable ecount1
from the source ecount1.c
, using the -g flag to turn on debugging information in the executable and the -o flag to name the output file ecount1
instead of the default a.out
.
Now we will try to run the program and see what happens.
bash$ ecount1
Usage: ecount <word>
We forgot to include the word for it to count the number of 'e's in! So it correctly gave us a usage message. Let's try again.
bash$ ecount1 example
Usage: ecount <word>
Oh dear. Even when we include an argument, it still gives us an error message. We could probably fix this one by inspecting the code, but this chapter is about using the debugger, so let's do that...