C语言教程
C语言控制语句
C语言函数
C语言数组
C语言指针
C语言字符串
C语言数学函数
C语言结构
C语言文件处理
C预处理器

C #undef

#undef预处理程序指令用于取消定义由#define定义的常量或宏。
语法:
#undef token
让我们看一个定义和取消定义常量的简单示例。
#include <stdio.h>
#define PI 3.14
#undef PI
main() {
   printf("%f",PI);
}
输出:
Compile Time Error: 'PI' undeclared
#undef指令用于在有限范围内定义预处理器常量,以便您可以再次声明常量。
让我们看一个定义和取消定义数字变量的示例。但在未定义之前,它曾被平方变量使用。
#include <stdio.h>
#define number 15
int square=number*number;
#undef number
main() {
   printf("%d",square);
}
输出:
225
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4