Is there a '#' operator in C ?
If yes then in the code
enum {ALPS, ANDES, HIMALYAS};
what would the following return ?
#ALPS
Is there a '#' operator in C ?
If yes then in the code
enum {ALPS, ANDES, HIMALYAS};
what would the following return ?
#ALPS
No.
#
is used for preprocessor directives, such as#include
and#define
. It can also be used inside macro definitions to prevent macro expansion.The C language does not have an
#
operator, but the pre-processor (the program that handles#include
and#define
) does. The pre-processor simple makes#ALPS
into the string"ALPS"
.However, this "stringify" operator can only be used in the
#define
pre-processor directive. For example:The pre-processor will convert the above example into the following:
There is no
#
operator in C. The#
prefix is used to delineate preprocessor instructions.See: http://en.wikipedia.org/wiki/C_preprocessor
"#" isn't an operator in C. But The preprocessor (which operates before the compiler) provides the ability for _ the inclusion of header files :
enter code here
#include _ macro expansions :**#define foo(x) bar x**
_ conditional compilation :In
enum {ALPS, ANDES, HIMALYAS};
Nothing would return ALPS. You've just defined a strong integer type(ALPS = 0, ANDES = 1 and HIMALYAS = 2)
, but it's useles without a name to this enumreation like this : enum mountain {ALPS, ANDES, HIMALYAS};The sharp symbol in C is the prefix for the preprocessor directives.
It is not an operator ...