Warning! You are warned against blindly copying the code statements. Read the code and understand the implementation. Then, try to do it yourself. Blindly re-typing the code statements is a waste of time & effort.
Table of contents:
1. Log messages based program debugging (Looks nice, Can't copy)
2. Log messages based program debugging (Copyable)
// DEMO: Log based Program Debugging
#include <stdio.h>
// Flag to control log messages
#define _DEBUG_ 1 // 0: Disable log msgs, 1: Enable log msgs
// Macro defintions
#if _DEBUG_
#define _ENTRY_ printf("ENTER: %s\n", __func__);
#define _EXIT_ printf("EXIT: %s\n", __func__);
#else
#define _ENTRY_
#define _EXIT_
#endif
int fun2()
{
_ENTRY_
printf("Fun 2 Processing part...\n");
int *px = NULL;
_EXIT_
return 0;
}
int fun1()
{
_ENTRY_
fun2();
_EXIT_
return 0;
}
int main()
{
_ENTRY_
fun1();
_EXIT_
return 0;
}