How to use #define DEBUG in C

2 Answers

0 votes
#include <stdio.h>

#define DEBUG

int main(void)
{
    printf("main start\n");

    #ifdef DEBUG
        printf("DEBUG\n");
    #endif

    printf("main end\n");

    return 0;
}




/*
run:

main start
DEBUG
main end

*/

 



answered Feb 9, 2023 by avibootz
0 votes
#include <stdio.h>

#define DEBUG

int main()
{
    #ifdef DEBUG
        printf("DEBUG is on\n");
    #endif

    #ifndef DEBUG
        printf("DEBUG is off\n");
    #endif

    return 0;
}




/*
run:

DEBUG is on

*/

 



answered Feb 9, 2023 by avibootz

Related questions

1 answer 136 views
1 answer 175 views
1 answer 184 views
1 answer 191 views
1 answer 164 views
1 answer 173 views
...