zoukankan      html  css  js  c++  java
  • 《黑马程序员》 预处理指令(C语言)

    预处理命令

       ①  宏定义

       ②  条件编译

       ③  文件包含

    宏定义:

       #define  A  5       不带参数的宏

          ①  所有的预处理命令都是以#开头;

          ②  预处理命令在程序翻译成0和1之前将程序中的A替换成5;

          ③  预处理的作用域是在预处理命令开始的那一行开始,到程序的结尾;

          ④  宏名一般用大写或者以看k开头,变量名一般用小写;

      #define pingfang(a)  ((a)*(a))

          ①  带参数的宏定义的参数必须每个都用括号扩住。

        

    条件编译:

    #define A 5
    
    #ifdef B
        printf("b
    ");
    #elif A
    #define A 5
    
    
    #if A
      printf("a");
    
    #endif
    
      如果定义了A 就编译下面的一句
    #if !A
    
       printf("ab");
    
    #endif
    
      如果没有定义A就编译下面的一句
    
        printf("a
    ");
    #endif
    
    
    #ifndef B
        printf("b
    ");
    #endif

      ①  如果定义了B 就输出b,否则如果定义了A就输出a;

      ②  有#ifdef必须有#endif;

     

    文件包含:

          ①  文件包含仅仅是文件复制;

        ②  文件包含不允许循环包含;

        ③  系统自带的文件使用<>包含,自己生明的文件使用 " " 包含;

  • 相关阅读:
    宿主机无法访问CentOS7上Jenkins服务的解决办法
    415. Add Strings
    367. Valid Perfect Square
    326. Power of Three
    258. Add Digits
    231. Power of Two
    204. Count Primes
    202. Happy Number
    172. Factorial Trailing Zeroes
    171. Excel Sheet Column Number
  • 原文地址:https://www.cnblogs.com/honey503775123/p/4335973.html
Copyright © 2011-2022 走看看