Earlier quoted context omitted.
He probably thought pointers are the only kind of variables and that he needed to dereference them. I imagine something like int *a = 1, *b = 2; printf("%d\n", *a && *b); Either that or he used `%s` as a format specifier. That seems more probable. Edit: Or, as I just realised the people below me meant, printf(a && b);
Nah mate, it's just some compiler flag that I didn't turn on (don't know which. my gcc-fu is fail since it's been really a long time since I touched C)
Why 1 && 2 == 2
11–20 of 58 posts
Re: Why 1 && 2 == 2
#12condition and truecase or falsecase
See "Boolean operations" and "Conditional expressions":
http://docs.python.org/3/reference/expressions.html#boolean-...
Re: Why 1 && 2 == 2
#13Earlier quoted context omitted.
I suck at C?
He probably thought pointers are the only kind of variables and that he needed to dereference them. I imagine something like int *a = 1, *b = 2; printf("%d\n", *a && *b); Either that or he used `%s` as a format specifier. That seems more probable. Edit: Or, as I just realised the people below me meant, printf(a && b);
Re: Why 1 && 2 == 2
#14Re: Why 1 && 2 == 2
#15Earlier quoted context omitted.
I suck at C?
He probably thought pointers are the only kind of variables and that he needed to dereference them. I imagine something like int *a = 1, *b = 2; printf("%d\n", *a && *b); Either that or he used `%s` as a format specifier. That seems more probable. Edit: Or, as I just realised the people below me meant, printf(a && b);
Re: Why 1 && 2 == 2
#16Earlier quoted context omitted.
He probably thought pointers are the only kind of variables and that he needed to dereference them. I imagine something like int *a = 1, *b = 2; printf("%d\n", *a && *b); Either that or he used `%s` as a format specifier. That seems more probable. Edit: Or, as I just realised the people below me meant, printf(a && b);
[deleted]
Re: Why 1 && 2 == 2
#17Earlier quoted context omitted.
He probably thought pointers are the only kind of variables and that he needed to dereference them. I imagine something like int *a = 1, *b = 2; printf("%d\n", *a && *b); Either that or he used `%s` as a format specifier. That seems more probable. Edit: Or, as I just realised the people below me meant, printf(a && b);
Or didn't put a format specifier, which makes sense coming from languages that don't have one in their print statements.
Re: Why 1 && 2 == 2
#18Earlier quoted context omitted.
Nah mate, it's just some compiler flag that I didn't turn on (don't know which. my gcc-fu is fail since it's been really a long time since I touched C)
Just for my curiosity's sake, would you mind posting the code you tried that segfaulted?
From the article, about the C version: "Mine hadn't worked, which I suspect is some sort of compiler issue."
Yeah I'm going to go out on a limb and proclaim that there's no way this was due to a compiler "issue" in gcc. Not that gcc is perfect, but there's no way it is barfing on one of these handful of line programs that does nothing but some logical operations and printfs.
Re: Why 1 && 2 == 2
#19For Python, a common idiom is to do this: condition and truecase or falsecase See "Boolean operations" and "Conditional expressions": http://docs.python.org/3/reference/expressions.html#boolean-...
Nowadays you would do this: truecase if condition else falsecase