#include <iostream>
//compares x to only a and b
#define equalTo(x, a, b) x != a && x != b
int main()
{
int x;
do
{
std::cout << "x = ";
std::cin >> x;
} while (equalTo(x, 1, 2)); //I wanna input as many as i want to be compared to "x"
//for example i want equalTo(x, 1, 2, 3, 4, 5) to work too, without a new macro
std::cout << "x = " << x;
std::cin.ignore();
std::cin.get();
return 0;
}
I was just playing around with code. I had an "if" statement that compared a variable to 13 numbers. So it was a pain and I thought I'd figure out a way to make it shorter and look cooler. :P