TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

C Tutorials

C Preprocessor Directives

Overview

C Preprocessor directives instruct the preprocessor to modify the C program before the compilation process. A preprocessor is a program that modifies the C program before compilation. The preprocessor directive statements begin with the #.

Examples

Some of the examples of the C Preprocessor Directives are as follows:

#include

To use a C standard library, we must include the library header file in the code using the #include directive.  For example, to include the stdio.h header file, we can use the following  #include directive statement.

#include <stdio.h>

C Preprocessor Directives

#define

The #define directive is used to instruct the preprocessor to replace the occurrences of the textual constant with the defined value. We can use this directive to define constants in the C program.

For example, to define the PI value we can use the following #define statement.

#define PI 3.14

 

Common Mistakes

To use the standard input and output library function in the C program we have to include the stdio.h header file. To avoid compilation warning messages like the one shown:

Error Include stdio.h Library Header File

Unlike the programming statements, there is no need to terminate the preprocessor directive by a semicolon.

Example:

#include <stdio.h>;

If you terminate a preprocessor directive with a semicolon compiler will throw a warning message. Sample warning message

warning: extra tokens at end of #include directive #include <stdio.h>;

To resolve the warning message, remove the semicolon in the preprocessor directive.

C extra tokens warning #include directive

Related Posts

C Language Characteristics

C Tutorials /

C Language Characteristics

C Source Code .c File

C Tutorials /

C Program Files & Formats

GNU Compiler Collection GCC

C Tutorials /

C Compilers

C Pointers

C Tutorials /

C Pointers

C Tutorials /

C Two-Dimensional Arrays

‹ C Program to compute Volume of the Cone› User-Defined Functions in C

Recent Posts

  • Update draw.io on Windows
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com