Printf Debugging: Explained for Beginners

  • Thread starter Thread starter chmate
  • Start date Start date
  • Tags Tags
    Debugging
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
3 replies · 4K views
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
 
Physics 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 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.