The valgrind utility can be use to detect dynamic memory problems
and to detect invalid memory accesses. To use valgrind make sure
you compile your code with the -g option.
To run valgrind:
valgrind a.out
If you are using input redirection:
valgrind a.out < public01.in
Other options:
valgrind --leak-check=full a.out /* for details of leaked memory */
valgrind --track-origins=yes a.out /* to track use of uninitialized values */
Additional information about valgrind can be found at http://pages.cs.wisc.edu/~bart/537/valgrind.html and http://valgrind.org/