Noeud:One More Time..., Noeud « Next »:, Noeud « Previous »:The Fourth Bug, Noeud « Up »:An example debugging session using gdb



One More Time...

When we recompile as ecount5 we get this result:

     bash$ ecount5 example
     The word is 'example'
     There are 2 'e's in 'example'.
     

Hurray! Finally it has worked correctly.

There are still a few things in the program which *will* catch us out later, though.

For instance, when we made buf into a local array defined on the stack, we only made it ten characters long. What will happen if someone enters Supercalifragilisticexpialidocious as a word? It will scribble all over the stack and the results will be completely undefined - it may work, it may crash, or most dangerous of all it may appear to work but actually have corrupted some other variables or the return address of the function, so it will crash when it returns, much later on...