C语言 - #else

C语言 - #else 首页 / C语言入门教程 / C语言 - #else

如果#if的条件为false,则#else预处理程序指令将评估表达式或条件。它可以与#if,#elif,#ifdef和#ifndef指令一起使用。

语法:

#if expression
//if code
#else
//else code
#endif

#elif的语法:

链接:https://www.learnfk.comhttps://www.learnfk.com/c-programming/c-preprocessor-else.html

来源:LearnFk无涯教程网

#if expression
//if code
#elif expression
//elif code
#else
//else code
#endif

C #else示例

让我们看一个使用#else预处理器指令的简单示例。

无涯教程网

#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

祝学习愉快!(内容编辑有误?请选中要编辑内容 -> 右键 -> 修改 -> 提交!)

技术教程推荐

左耳听风 -〔陈皓〕

从0开始做增长 -〔刘津〕

许式伟的架构课 -〔许式伟〕

TensorFlow 2项目进阶实战 -〔彭靖田〕

跟月影学可视化 -〔月影〕

如何看懂一幅画 -〔罗桂霞〕

A/B测试从0到1 -〔张博伟〕

中间件核心技术与实战 -〔丁威〕

AI大模型系统实战 -〔Tyler〕

好记忆不如烂笔头。留下您的足迹吧 :)