Debugging with printf
In this section, we will learn how the classic approach of logging via printf is still one of our go-to debugging approaches. We will see how it holds up today, how it has evolved over the years, and how it can be used to our advantage.
What is printf?
printf is a C standard library function whose purpose is to print formatted text to some output interface or console. The principal idea of printf is pretty much available in every programming language. So, what is discussed in this section will apply to any programming language that is viable for embedded target devices and that has some sort of standard output function.
The standard definition of printf is as follows:
int printf ( const char * format, ... );
The function takes a string or char array as an input parameter, which can have format specifiers applied. The return value will output how many characters were written on success. On error, it will return a negative number, and depending on the library implementation...