Monday, January 7, 2008

C++ Pre Processor Commands

When you write C++ programs ( Specially when error handling )you might need to get running file name, current execution line and system time. Following program demonstrate that.

//
// File: PreProcessorCommands.cc
// Author: eranga
//
// Created on January 7, 2008, 5:24 PM
//

#include
#include
using namespace std;

//
//
//
int main(int argc, char** argv) {

cout << "File Name : " << __FILE__ << endl;
cout << "Current Time : " << __TIME__ << endl;
cout << "Current Line : " << __LINE__ << endl;

return (EXIT_SUCCESS);
}

No comments: