zoukankan      html  css  js  c++  java
  • c++ 预处理的应用

    //
    //  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 之间的消息将不会被输出

  • 相关阅读:
    用servlet来实现验证码的功能
    Sqlite3 数据库
    xml解析
    Android .9文件
    AsyncTask
    Looper Handler
    URLConnection
    单例模式
    Httpclient访问网络
    json 解析
  • 原文地址:https://www.cnblogs.com/zhuyaguang/p/4727781.html
Copyright © 2011-2022 走看看