why we use # as preprocessor in c++?
why we dont use any other symbol like @,$,%,& etc. as preprocessors?

include Recall that preprocessing is the first step in the C program compilation stage -- this feature is unique to C compilers.

The preprocessor more or less provides its own language which can be a very powerful tool to the programmer. Recall that all preprocessor directives or commands begin with a #.

Use of the preprocessor is advantageous since it makes:

programs easier to develop,
easier to read,
easier to modify
C code more transportable between different machine architectures.
The preprocessor also lets us customise the language. For example to replace { ... } block statements delimiters by PASCAL like begin ... end we can do.

This directive includes a file into code.
It has two possible forms:

#include <file>

or

     #include "file"

<file> tells the compiler to look where system include files are held. Usually UNIX systems store files in $\backslash$usr$\backslash$include$\backslash$ directory.

"file" looks for a file in the current directory (where program was run from)

Included files usually contain C prototypes and declarations from header files and not (algorithmic) C code (SEE next Chapter for reasons)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.