Softpanorama
(slightly skeptical) Open Source Software Educational Society

May the source be with you, but remember the KISS principle ;-)

Softpanorama Search

Typical Errors in C

Lint is a great tool. repeat after me lint is a great tool and if somebody is not using it he/she is does not respect himself and his time... It's simply stupid to spent time debugging errors that lint can find.

  1. Non-terminated comment, "accidentally" terminated by some subsequent comment, with the code in between swallowed.
            a=b; /* this is a bug
            c=d; /* c=d will never happen */
  2. Accidental assignment/Accidental Booleans
            if(a=b) c;      /* a always equals b */

    Depending on your viewpont, the bug in the language is that the assignment operator is too easy to confuse with the equality operator; or maybe the bug is that C doesn't much care what constitutes a boolean expression: (a=b) is not a boolean expression! (but C doesn't care)


Lint, Debugging

See also Softpanorama Debugging Links

Typical errors



Copyright © 1996-2009 by Dr. Nikolai Bezroukov. www.softpanorama.org was created as a service to the UN Sustainable Development Networking Programme (SDNP) in the author free time. Submit comments This document is an industrial compilation designed and created exclusively for educational use and is placed under the copyright of the Open Content License(OPL). Site uses AdSense so you need to be aware of Google privacy policy. Original materials copyright belong to respective owners. Quotes are made for educational purposes only in compliance with the fair use doctrine.

Disclaimer:

Last modified: August 15, 2009