Debugging C Programs

The C compiler is liberal about the kinds of constructs it allows in programs. In keeping with the UNIX philosophy that “no news is good news” and that the user knows what is best, gcc, like many other GNU/Linux utilities, accepts almost anything that is logically possible according to the definition of the language. Although this approach gives the programmer a great deal of flexibility and control, it can make debugging difficult.

Figure 16-4 shows badtabs.c, a flawed version of the tabs.c program discussed earlier. It contains some errors and does not run properly but illustrates some debugging techniques.

Figure 16-4. The badtabs.c program (The line numbers are not part of the source code; the arrows point to errors in ...

Get A Practical Guide to Red Hat® Linux® 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.