Before going to write C program for this problem, I would like to give some information about some predefined Macros in C language.
__FILE__ is a predefined macro in C that expands to the name of the current input file as a string.
__DATE__ is a predefined macro in C that expands to current date at the compile time in the form of MMM DD YYYY as a string. E.g. Nov 10 1991
__TIME__ is a predefined macro in C that expands to current time at the compile time in the form of HH : MM : SS in 24 hours time as a string. E.g. 21:45:15
__LINE__ is a predefined macro in C that expands to current input line number as a decimal.
__STDC__ is a predefined macro in C that expands to the constant 1, to signify that this compiler conforms to ANSI C.
Now, I’m giving a solution to this problem in a very simple way. I hope, it would be helpful for you.
#include<stdio.h>
void acTestMacro ( )
{
printf( ” File : %s\n Date : %s\n Time : %s \n Line : %d\n STDC : %d\n”,__FILE__, __DATE__, __TIME__, __LINE__, __STDC__ );
}
int main ( int argc, char *argv )
{
acTestMacro();
return 0;
}
Hope, it would be helpful.
To contribute :
If you like Advance Computing and would like to contribute, you can mail your article to “computingadvance@gmail.com”. You will get credit as your name , email id, designation with article on this blog.