C Sharperror - C Programming Tutorial
C Course / Preprocessor / C Sharperror

C Sharperror

BLUF: Understanding C Sharperror 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 Sharperror

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

C #error

Let's explore a basic illustration of employing the #error preprocessor directive.

Example

Example

#include<stdio.h>
#include <math.h>

#ifndef __MATH_H

#error First include then compile

#else

void main(){

    float a;

    a=sqrt(7);

    printf("%f",a);

}

#endif

Output:

Output

Compile Time Error: First include then compile

However, when you include math.h, it does not produce an error.

Example

Example

#include<stdio.h>

#include<math.h>

#ifndef __MATH_H

#error First include then compile

#else

void main(){

    float a;

    a=sqrt(7);

    printf("%f",a);

}

#endif

Output:

Output

2.645751

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