#define DEBUG
#ifdef DEBUG
調試代碼
#endif
#include<iostream>
#include <string>
using namespace std;
bool debug =false;
int main(int argc,char*argv[])
{
for(int i=0;i<argc;i++)
if(string(argv[i])==“--debug=on“)
debug = true;
bool go=true;
while(go)
{
if(debug)
{
調試代碼
}else {}
}
}
3、把變量和表達式轉換成字符串 可是使用字符串運算符來實現轉換輸出定義 #define PR(x) cout<<#x”=”<<x<<'/n'
4、c語言的assert() 該宏在中,,當使用assert時候,給他個參數,即一個判讀為真的表達式。預處理器產生測試該斷言的代碼,假如斷言不為真,則發出一個錯誤信息告訴斷言是什么以及它失敗一會,程序會終止。
#include< assert>
using namsapce std;
int main()
{
int i=100;
assert(i!=100);
//Fails
}
當調試完畢后在#include<assert>前新聞熱點
疑難解答