Aleph
Aleph

Reputation: 223

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 inside the #ifdef #endif section?

reference

Upvotes: 1

Views: 175

Answers (1)

Tofu
Tofu

Reputation: 3613

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.

Upvotes: 2

Related Questions