Important preprocessor constants
__DATE__
__FILE__
__LINE__
__TIME__
#include<stdio.h>
//#include<conio.h>
int main()
{
//clrscr();
printf("Date on which the file is modified of file %s\n",__DATE__);
printf("Name of the file being processed %s\n",__FILE__);
printf("Number of line on which this command is wrriten %d\n",__LINE__);
printf("time of processing of cureent file (last modified time )%s\n",__TIME__);
getch();
return(0);
}
/* Output */ Date on which the file is modified of file Jun 19 2020 Name of the file being processed E:\codeblocks\ccc1\main.c Number of line on which this command is wrriten 8 time of processing of cureent file (last modified time )10:58:14
Pragma
“pragma” statement helps us to execute some functions before the execution of the main function and after the execution of the main function.
To execute before main function :
#pragma startup <function_name> [priority]
To execute after main function
#pragma exit <function_name> [priority]
Example : (without priority)
#pragma startup xyz
#pragma exit abc
Example : (with priority )
#pragma startup xyz 64
#pragma startup xyz1 65
#pragma exit abc 64
These two pragma’s allow the program to specify function(s) that should be called either:
startup–before main() is called
exit–just before the program terminates (after main function)
<function_name> must be a previously declared function that takes no arguments and returns void. It should be declared as
void func(void);
The function name must be defined (or declared) before the pragma line is reached.
[priority]
The optional priority parameter is an integer in the range 64 to 255.
Startup : lower to higher priority
Exit : higher to lower priority
Example:1
#include<stdio.h>
#include<conio.h>
void abc();
void xyz();
#pragma startup xyz
#pragma exit abc 64
void main()
{
printf("hi\n");
getch();
}
void xyz()
{
clrscr();
printf("Starting\n");
getch();
}
void abc()
{
printf("Ending\n");
getch();
}
Example:2
#include<stdio.h>
#include<conio.h>
void abc();
void xyz();
void xyz1();
#pragma startup xyz 64
#pragma startup xyz1 65
#pragma exit abc 64
void main()
{
printf("hi");
getch();
}
void xyz()
{
clrscr();
printf("Starting\n");
getch();
}
void xyz1()
{
printf("good start\n");
}
void abc()
{
printf("Ending\n");
getch();
}
Example:3
#include<stdio.h>
#include<conio.h>
void abc();
void abc1();
void abc2();
void xyz();
void xyz1();
#pragma startup xyz 64
#pragma startup xyz1 65
#pragma exit abc 64
#pragma exit abc1 65
#pragma exit abc2 66
void main()
{
printf("hi");
getch();
}
void xyz()
{
clrscr();
printf("Starting xyz function before main 64\n");
getch();
}
void xyz1()
{
printf("good start beforem main 65\n");
}
void abc()
{
printf("Ending abc function after main 64\n");
getch();
}
void abc1()
{
printf("abc 1 function 65\n");
getch();
}
void abc2()
{
printf("abc 2 function 66\n");
getch();
}




