Skip to content

Instantly share code, notes, and snippets.

@kinoshita-lab
Created July 18, 2013 02:55
Show Gist options
  • Save kinoshita-lab/6026362 to your computer and use it in GitHub Desktop.
Save kinoshita-lab/6026362 to your computer and use it in GitHub Desktop.
ternary conditional expression as an argument
#include <cstdlib>
#include <cstdio>
#include <stdint.h>
void func(bool a)
{
if (a) {
puts("true");
} else {
puts("false");
}
}
int main(void)
{
for (int i = 0; i < 10; ++i) {
const int v = rand();
func(v % 2 ? true : false);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment