How to write a code for debugging to print variable and variable value in C

1 Answer

0 votes
#include <stdio.h>
 
#define DebugPrint(x) printf("value of \"%s\" is: %d\n",#x, x);
 
int main()
{
    int n1;
    int n2;
     
    n1 = 13;
    n2 = 87;
     
    DebugPrint(n1);
    DebugPrint(n2);
     
    return 0;
}
   
     
/*
       
run:
 
value of "n1" is: 13
value of "n2" is: 87
 
*/

 



answered Jul 7, 2018 by avibootz

Related questions

1 answer 166 views
166 views asked Jul 29, 2017 by avibootz
1 answer 179 views
1 answer 171 views
6 answers 422 views
422 views asked Jul 26, 2017 by avibootz
6 answers 397 views
2 answers 137 views
...