获取函数的名字
c99標準中的__func__預定義標識符功能可以幫我們獲取函數的名稱
#include<string> #include<iostream> using namespace std;const char *hello(){return __func__; }int main(){cout<<hello()<<endl;return 0; }代碼中的函數相當于:
const char *hello(){static const char * __func__="hello";return __func__; }總結
- 上一篇: 四星酒多少钱啊?
- 下一篇: c获取文件的名字和运行到程序的第几行功能