Skip to content

Instantly share code, notes, and snippets.

@kaityo256
Created July 14, 2017 00:43
Show Gist options
  • Save kaityo256/229a9bf545f91bd58429645a34e0e00d to your computer and use it in GitHub Desktop.
Save kaityo256/229a9bf545f91bd58429645a34e0e00d to your computer and use it in GitHub Desktop.
A sample using ternary operators
#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
}
@kaityo256
Copy link
Author

最後のケースでは、int aunsigned intにキャストされている。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment