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

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

技术教程推荐

技术与商业案例解读 -〔徐飞〕

Go语言核心36讲 -〔郝林〕

玩转Git三剑客 -〔苏玲〕

10x程序员工作法 -〔郑晔〕

Node.js开发实战 -〔杨浩〕

Redis核心技术与实战 -〔蒋德钧〕

手把手带你搭建秒杀系统 -〔佘志东〕

朱涛 · Kotlin编程第一课 -〔朱涛〕

LangChain 实战课 -〔黄佳〕

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