C Sharpundef - C Programming Tutorial
C Course / Preprocessor / C Sharpundef

C Sharpundef

BLUF: Understanding C Sharpundef is a foundational part of learning C programming. This tutorial explains the core principles and syntax needed to implement this concept effectively.
Core Programming Principle: C Sharpundef

C provides direct access to memory and system resources. Learn how C Sharpundef leverages this power in the lesson below.

C #undef

Example

#undef token

Let's explore a basic illustration of how to declare and remove a constant.

Example

Example

#include <stdio.h>

#define PI 3.14

#undef PI

main() {

   printf("%f",PI);

}

Output:

Output

Compile Time Error: 'PI' undeclared

The #undef directive is employed to specify the preprocessor constant within a specific scope, allowing you to redefine the constant if needed.

Let's explore a scenario where we declare and then clear a numeric variable. Prior to its removal, this variable was referenced by another variable called square.

Example

Example

#include <stdio.h>

#define number 15

int square=number*number;

#undef number

main() {

   printf("%d",square);

}

Output:

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience