August 2001
Beginner
482 pages
10h 52m
English
The preprocessor provides two special operators for manipulating strings in macros. The stringizing operator (#) substitutes a quoted string for whatever follows the stringizing operator. The concatenation operator (##) bonds two strings together into one.
The stringizing operator(#) puts quotes around any characters following the operator, up to the next white space. So, if you write:
#define WRITESTRING(x) cout << #x
and then call
WRITESTRING(This is a string);
the precompiler will turn it into this:
cout << "This is a string";
Note that the string This is a string is put into quotes, as required by cout.
The concatenation operator (##) enables you to bond together more than one term into ...
Read now
Unlock full access