Reputation: 23031
Why are newlines, spaces and tabs ignored by # in a macro and replaced by exactly one space?
Is there a way to get theses white spaces into the string generated by #?
Example:
#include <iostream>
using namespace std;
#define TOSTR(s) #s
int main() {
cout <<
TOSTR(a newline at the end please
three spaces
tab first
) << endl;
}
Output:
a newline at the end please three spaces tab first
(There are no newlines, no three spaces and no tab)
Upvotes: 0
Views: 256