Tuesday, October 21, 2014

Predefined C Macros



1. C Program that print current DATE




#include <stdio.h>

int main(){

printf("Current date: %s",__DATE__); //calculate the current date

}



2. C Program that print current TIME



#include <stdio.h>

int main(){

printf("Current time: %s",__TIME__); //calculate the current time

}






3. C Program that print name of the file



#include <stdio.h>

int main(){

printf("File Name: %s",__FILE__); //calculate the name of the file

}





4. C++ Program that print integer constant



#include<iostream.h>

main()

{

cout<<__MSDOS__;

}



5. C Program that print line number of the file



#include <stdio.h>

int main(){

printf("Line Number: %d",__LINE__); //calculate the line number of file

}


No comments:

Post a Comment