#include <stdio.h>
#define x 10
void foo();
void main()
{
printf("%d\n",x);
foo();
printf("%d\n",x);
}
void foo()
{
#undef x
#define x 20
}
Output:
10
10
ConCept:
During preprocessing, the compiler checks for preprocessor directive sequential, it's that time when code is not yet compiled, so both 'x' are replaced by 10.
#define x 10
void foo();
void main()
{
printf("%d\n",x);
foo();
printf("%d\n",x);
}
void foo()
{
#undef x
#define x 20
}
Output:
10
10
ConCept:
During preprocessing, the compiler checks for preprocessor directive sequential, it's that time when code is not yet compiled, so both 'x' are replaced by 10.
No comments:
Post a Comment