Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

EXPERT C OPERATOR REIMPLEMETATION

Name: Anonymous 2015-07-31 22:48

#include <stdbool.h>

bool
or (bool a, bool b)
{
return a ? true : (b ? true : false);
}

bool
and (bool a, bool b)
{
return a ? (b ? true : false) : false;
}

bool
not (bool a)
{
return a ? false : true;
}


#include <iso646.h>
#include <stdbool.h>
#include <stdio.h>

int main(void)
{
bool one = true;
bool two = false;

printf("%d, %d, %d\n", (one or two), (one and two), (not one));
return 0;
}


$ gcc -o a a.c -std=c99 && ./a
1, 0, 0

Name: Anonymous 2015-07-31 23:01

Was the second part in the original?

Name: Anonymous 2015-08-01 5:15

In case there are any n00bs reading, OP is a troll. The or/and/not used in main are not the same as the ones OP defined.

Name: Anonymous 2015-08-02 3:49

PYTHON-LIKE MACROS IN C:

#define and [spoiler]== 0 ? 0 : [/spoiler]
#define or [spoiler]? [spoiler]DIRTYOLDDICKEATERGETSRAPEDBYDEVOPSPROS[/spoiler] : [/spoiler]

assert(2 and 3 == 3);
assert(2 or 3 == 2);
assert(5 and 0 == 0);

Name: Anonymous 2015-08-02 4:54

>>4
you don't know how to [code][/code] cancel you are pathetic!

Don't change these.
Name: Email:
Entire Thread Thread List