|
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++中取得当前文件名与行数内容请搜索靠谱客的其他文章。
发表评论 取消回复