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
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:
#define MAKE_STRING_OF_IDENTIFIER(x) #x
char alps[] = MAKE_STRING_OF_IDENTIFIER(ALPS);
The pre-processor will convert the above example into the following:
char alps[] = "ALPS";
There is no #
operator in C. The #
prefix is used to delineate preprocessor instructions.
See: http://en.wikipedia.org/wiki/C_preprocessor
No. #
is used for preprocessor directives, such as #include
and #define
. It can also be used inside macro definitions to prevent macro expansion.
The sharp symbol in C is the prefix for the preprocessor directives.
It is not an operator ...
"#" 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 :
**#if DLEVEL > 5
#define STACK 200
#else
#define STACK 50
#endif
#endif**
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};