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 171 views
171 views asked Jul 29, 2017 by avibootz
1 answer 183 views
1 answer 178 views
6 answers 425 views
425 views asked Jul 26, 2017 by avibootz
6 answers 401 views
2 answers 140 views
...