Preprocessor Directives in C


The C Preprocessor is not a part of the compiler, but is a separate step in the compilation process. In simple terms, a C Preprocessor is just a text substitution tool and it instructs the compiler to do required pre-processing before the actual compilation. We'll refer to the C Preprocessor as CPP.

Preprocessing directives are lines in your program that start with # . It must be the first nonblank character, and for readability, a preprocessor directive should begin in the first column.

Source Code

//Preprocessor Directives  in C Programming
 
#include<stdio.h>
#define LIMIT 5
#define MSG "Tutor Joes"
 
#define custom_message(a)\
printf("\n" #a " Welcome to our institution")
 
int main()
{
 
    for(int i=0;i<LIMIT;i++)
    {
        printf("\n%d",i);
    }
 
    printf("\n%s",MSG);
    custom_message("Ram Kumar");
 
    printf("\nFile Name  : %s",__FILE__);
    printf("\nTime       : %s",__TIME__);
    printf("\nLINE       : %d",__LINE__);
 
    return 0;
}
 

Output

0
1
2
3
4
Tutor Joes
"Ram Kumar" Welcome to our institution
File Name  : C:\Users\tutor\Desktop\C_CLASS\01)Prepro.c
Time       : 15:24:48
LINE       : 21
To download raw file Click Here

List of Programs


Sample Programs


Switch Case in C


Conditional Operators in C


Goto Statement in C


While Loop Example Programs


Looping Statements in C

For Loop Example Programs


Array Examples in C

One Dimensional Array


Two Dimensional Array in C


String Example Programs in C


Functions Example Programs in C