#define LOWER 30
void main()
{
int i;
for (i=1;i<=LOWER; i++)
{
printf("\n%d", i);
}
}
#define AREA(a) (3.14 * a * a)
void main()
{
float r = 3.5, x;
x = AREA (r);
printf ("\n Area of circle = %f", x);
}
Macro | Description |
---|---|
___LINE___ | It contains a current line number as a decimal constant. |
___FILE___ | It contains the current filename as a string literal. |
___DATE___ | It shows the current date as a character literal in the “MMM DD YYYY” format. |
___TIME___ | It shows the current time as a character literal in “HH:MM:SS” format. |
___STDC___ | It is defined as 1 when the compiler complies with the ANSI standard. |
___TIMESTAMP___ | It is a sing literal in the form of “DDD MM YYYY Date HH:MM:SS”. It is used to specify the date and time of the last modification of the current source file. |
#if TEST <= 5
statement 1;
statement 2;
#else
statement 3;
statement 4;
#endif
Directives | Description |
---|---|
#define | It substitutes a preprocessor macro. |
#include | It inserts a particular header file from another file. |
#undef | A preprocessor macro is undefined. |
#ifdef | It returns true if the macro is defined. |
#ifndef | It returns true if the macro is not defined. |
#if | It tests if the compile time condition is true. |
#else | It is an alternative for #if. |
#elif | It has #else and #if in one statement. |
#endif | The conditional preprocessor is ended. |
#error | It prints the error message on stderr. |
#pragma | It issues special commands to the compiler by using a standardized method. |