0

The # operator in Macros replaces the argument name with a string representing that argument name like:

#define MACRO(something) #something

#include <iostream>

int main()
{
    std::cout << MACRO(wow); // it will print the string "wow"

    return 0;
}

But can we reverse this, like send a string as a parameter and replace the string with the string content, idk how to explain so i will show you another example:

#define MACRO(something) (operator)something //converts the something argument which is a string to plain text

#include <iostream>

int main()
{
    int MACRO("anything") = 0;

    std::cout << MACRO("anything"); //it will print out 0

    return 0;
}
Claudiu HBann
  • 56
  • 1
  • 9

0 Answers0