Key Words:__FILE__ ,__LINE__ , File Name , Line Number
/*===========================================*/ #include <iostream> using namespace std; const char * GetFileName( const char* path,const char* sep) cnt = strlen(path); if( NULL == temp) for(int i = 0;i<cnt;i++,temp++) return cRet; void PrintLineNum( long line ) int main() cout<<"The file path is: "__FILE__<<endl; pFile = GetFileName( __FILE__ ,"//" ); cout<<"The File Name Is :"<<pFile<<endl; PrintLineNum( __LINE__ ); // just to have a pause /*===========================================*/ 该程序的执行结果如下: The file path is: C:/Documents and Settings/wood/デスクトップ/test/test.cpp |
C/C++中取得当前文件名与行数
C/C++中取得当前文件名与行数
2007-10-16 13:40