Printf Debugging: Explained for Beginners

  • Thread starter Thread starter chmate
  • Start date Start date
  • Tags Tags
    Debugging
AI Thread Summary
Printf debugging involves inserting print statements in code to track the program's internal behavior and monitor important calculations. This method, sometimes referred to as "instrumentation," is particularly useful when traditional debugging tools are unavailable or when working with a serial interface. While effective for gaining insights into code execution, it is considered a slower debugging approach compared to using dedicated debugging software, which allows for direct code examination. For those new to programming, understanding and implementing printf debugging can provide valuable experience in tracking down issues, even though investing in a debugger may offer a more efficient solution.
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.
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
Thread 'Project Documentation'
Trying to package up a small bank account manager project that I have been tempering on for a while. One that is certainly worth something to me. Although I have created methods to whip up quick documents with all fields and properties. I would like something better to reference in order to express the mechanical functions. It is unclear to me about any standardized format for code documentation that exists. I have tried object orientated diagrams with shapes to try and express the...

Similar threads

Back
Top