Short-circuit and and or.

Pages: 12
rocketboy9000 wrote:
Maybe, but this is like giving me a chrome steel spoon with tungsten carbide serrations and then telling me NOT to use it for my Haagen-Dazs.
Nope, it's like giving you logical operators and tell you NOT to use them as control structures

Very readable code:
1
2
3
4
5
6
7
8
9
#include <csetjmp>
#include <iostream>
using namespace std;
int main()
{
    jmp_buf jmp;
    char c;
    ( ( setjmp ( jmp ) && cout << "Please enter [Y]es or [N]o\n" ), false ) ||  cout << "Do you like spagetti code? " && cin >> c && ( ( ( c == 'y' || c == 'Y' ) && cout << "So do I" ) || ( c == 'n' || c == 'N' ) && cout << "I do" || (longjmp(jmp,1), true) );
}
Last edited on
Topic archived. No new replies allowed.
Pages: 12