C Predefined Macros in C Language
Categories: C language
ANSI C defines many predefined macros that can be used in c program.
No.MacroDescription
1_DATE_represents current date in "MMM DD YYYY" format.
2_TIME_represents current time in "HH:MM:SS" format.
3_FILE_represents current file name.
4_LINE_represents current line number.
5_STDC_It is defined as 1 when compiler complies with the ANSI standard.
C predefined macros example
File: simple.c
#include<stdio.h>
int main(){
printf("File :%s\n", __FILE__ );
printf("Date :%s\n", __DATE__ );
printf("Time :%s\n", __TIME__ );
printf("Line :%d\n", __LINE__ );
printf("STDC :%d\n", __STDC__ );
return 0;
}
Output:
File :simple.c
Date :Dec 6 2015
Time :12:28:46
Line :6
STDC :1