#include <stdio.h>

// NUM叫做宏名
// 6是用来替换宏名的字符串
#define NUM 6

#define mul(a, b) ((a)*(b))


void test() {
    // 双引号中的NUM并不会被替换为6
    char *s = "NUMBER";
    
    
    
    int a[NUM] = {1,2,3,4,5,6};
    
    for (int i = 0; i<NUM; i++) {
        printf("a[%d] = %d\n", i , a[i]);
    }
}

int main(int argc, const char * argv[])
{
    int a = mul(10, 10) / mul(2, 2);
    // mul(a, b) (a)*(b)
    // (10 * 10) / (2 * 2)
    printf("%d", a);
    return 0;
}

 

相关文章:

  • 2021-10-12
  • 2021-06-07
  • 2022-12-23
  • 2022-12-23
  • 2022-01-30
猜你喜欢
  • 2021-06-06
  • 2021-06-25
  • 2021-08-06
  • 2022-02-23
  • 2022-12-23
  • 2021-11-20
相关资源
相似解决方案