Printf Debugging: Explained for Beginners

  • Thread starter Thread starter chmate
  • Start date Start date
  • Tags Tags
    Debugging
Click For Summary

Discussion Overview

The discussion revolves around the concept of "printf debugging," exploring its purpose, implementation, and utility in programming. Participants share their perspectives on the terminology and methods associated with this debugging technique.

Discussion Character

  • Exploratory, Technical explanation, Debate/contested

Main Points Raised

  • One participant seeks clarification on the necessity and application of printf debugging.
  • Another participant describes printf debugging as placing print statements in code to observe internal behavior, suggesting it may be a simplistic term.
  • A different participant proposes "instrumentation" as a more comprehensive term for the practice.
  • One participant explains that instrumentation is useful when direct access to a debugger is unavailable, detailing the process of adding print statements and compiling to view results, while noting it can be a slow debugging method.
  • Another participant argues that using a debugger is generally easier and mentions the availability of affordable debugging tools.

Areas of Agreement / Disagreement

Participants express differing views on the terminology and methods of debugging, with no consensus on the superiority of printf debugging versus using a debugger.

Contextual Notes

Some participants highlight the limitations of printf debugging, such as its slow nature and the context in which it is most useful, but these points remain unresolved.

chmate
Messages
37
Reaction score
0
Hi there,

I'm noob at programming. Can anyone explain me why we need printf debugging, how to implement it, and for what is used it?

Thank you
 
Technology news on Phys.org
"Printf debugging" is a rather dumb term to describe placing print statements throughout your code, often printing the value of important intermediate calculations, so that you can observe the program's internal behavior.

- Warren
 
"instrumentation" may a better, more all-inclusive term.
 
Instrumentation is normally used in situations where you can't get at the code with a debugger but you have accesses to some kind of serial interface to a terminal. Then the printf statements send messages to the terminal. You just enter the printf statements in the code, compile and then look at the results. Enter more printfs, compile and look at the results. It is a SLOW way to debug.

In most cases, it is easier to simply use an inexpensive debugger and look at the code directly. You can get a Visual Basic or Visual C++ debugger for around $100 these days.
 

Similar threads

  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 5 ·
Replies
5
Views
6K
  • · Replies 31 ·
2
Replies
31
Views
4K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 32 ·
2
Replies
32
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 12 ·
Replies
12
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 6 ·
Replies
6
Views
6K
Replies
1
Views
2K