C++ – How does one execute a no-op in C/C++


for the following:

( a != b ) ? cout<<"not equal" : cout<<"equal";

suppose I don't care if it's equal, how can I use the above statement by substituting cout<<"equal" with a no-op.

Best Solution

If it really is for a ternary operator that doesn't need a second action, the best option would be to replace it for an if:

if (a!=b) cout << "not equal";

it will smell a lot less.