Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

What is the role of identifier in C preprocessor directives

When I execute the following code, the output is 5 6.

int main()
{
    int one = 5, two = 6;
    #ifdef next
    one = 2;
    two = 1;
    #endif
        printf("%d %d", one, two);
    return 0;
}

Definitely the code within #ifdef #endif is not getting excuted.
I am unable to understand the utility of the identifier next. What is the keyword instead of next that will make the compiler execute the code inseide the #ifdef #endif section?

reference

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You simply define the macro

#define next
int main()
{
    int one = 5, two = 6;
    #ifdef next
    one = 2;
    two = 1;
    #endif
        printf("%d %d", one, two);
    return 0;
}

Now the values will change.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading