Created
July 14, 2017 00:43
-
-
Save kaityo256/229a9bf545f91bd58429645a34e0e00d to your computer and use it in GitHub Desktop.
A sample using ternary operators
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <stdio.h> | |
| void func(int a){ | |
| printf("int %d\n",a); | |
| } | |
| void func(unsigned int a){ | |
| printf("unsigned int %d\n",a); | |
| } | |
| int | |
| main(void){ | |
| int a = 2, b = 1; | |
| unsigned int c = 1; | |
| func(a); // int 2 | |
| func(c); // unsigned int 1 | |
| func(a > b? a : c); // unsigned int 2 | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
最後のケースでは、
int aがunsigned intにキャストされている。