如果#if的条件为false,则#else预处理程序指令将评估表达式或条件。它可以与#if,#elif,#ifdef和#ifndef指令一起使用。
语法:
#if expression //if code #else //else code #endif
#elif的语法:
#if expression //if code #elif expression //elif code #else //else code #endif
让我们看一个使用#else预处理器指令的简单示例。
链接:https://www.learnfk.comhttps://www.learnfk.com/c-programming/c-preprocessor-else.html
来源:LearnFk无涯教程网
#include <stdio.h> #include <conio.h> #define NUMBER 1 void main() { #if NUMBER==0 printf("Value of Number is: %d",NUMBER); #else print("Value of Number is non-zero"); #endif getch(); }
输出:
Value of Number is non-zero
祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)