LoginSignup
13
2

More than 5 years have passed since last update.

C言語でもa == 1 && a == 2 && a == 3をtrueにしてみたい

Posted at

先日、こんな記事を書いて、Rubyで a == 1 && a == 2 && a == 3 をtrueにしてみましたが、Cのようなレガシーな言語でも同様のことに成功しました。

#include <stdio.h>

int main(void)
{
    int a = 1;

#define a 1 || a

    if(a == 1 && a == 2 && a == 3) {
      printf("true\n");
    } else {
      printf("false\n");
    }
    return 0;
}
13
2
3

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
2