Techniques for avoiding problems in C programming

To ensure memory is not used uninitialized, compile with gcc -O -Wall or run the program under valgrind. The optimization flag -O is necessary to catch uninitialized variable errors.

To catch errors of the form if (c = 1), compile with gcc -Wall.

To prevent using freed memory, set pointers to zero after "free".

Copyright © Ben Bullock 2009-2023. All rights reserved. For comments, questions, and corrections, please email Ben Bullock ( or use the discussion group at Google Groups. / Privacy / Disclaimer