// // main.cpp // test // // Created by YaguangZhu on 15/6/25. // Copyright (c) 2015年 YaguangZhu. All rights reserved. // #include <stdio.h> #include "stdlib.h" #define DEBUG int main() { int i=0; char c; while (1) { i++; c= getchar(); if (c !=' ') { getchar(); } if (c =='q'||c=='Q') { #ifdef DEBUG printf("we got:%c,about to exit. ",c); #endif break; }else { printf("i = %d",i); #ifdef DEBUG printf(", we got :%c",c); #endif printf(" "); } } return 0; }
1
i = 1, we got :1
2
i = 2, we got :2
a
i = 3, we got :a
q
we got:q,about to exit.
如果注释第四行,debug没有被定义,那么#ifdef #endif 之间的消息将不会被输出