Hello all,
See the code ....
int i=-3,j=2,k=0,m;
m=++i;&&++j||++k;
printf ("%d %d %d %d",i,j,k,m);
I executed this code on gcc. the o/p i had got is:-
-2 3 0 1
Now my question is why k is not getting incremented? As per precedence
of C, first of all, All the unirary increments should take effect. but
in above, first logical operator is evaluated and as left hand side of
logical OR is 1, k do not increment? Then is C's precedence is not
followed here? Plz help????????
The program below should explain things for you. Kindly copy and paste it
into a separate file and present it to your standards-compliant compiler.
Run the program and carefully note the output. Best Regards.
P.S. Perhaps you could enlighten me as to whether applying the ! operator
to the return of function they is a portable thing to do.
#include <stdio.h>
#define /*Your question*/ about "the || operator is not "
#define often "evaluated " /* in this newsgroup, */
#define so "when " /* I saw it I realised that */
#define it " is true"
#define that "the left"/*ist commies in c.l.c suppress */ it "\n"
#define The "right of " /*discussion*/ about /* the || operator is */\
often /* repressed */ so that
#define w "he "/*n it arises few of us understand it.*/ The
long /*list of the*/ many (char/*acters*/ *who, float/*ed*/
by, size_t /*up the*/situation){/*and*/ return/*ed home
with */ 0 /* knowledge*/;}/*is*/ int/*eterpreted*/ by,
/*the*/ naive, /*as due to*/ new, trolling;
typedef /*Actually, the*/ char/*isma of those*/ post/*ers*/;
#define did /*the opposite. It is a */ stderr /*that for*/
#define s/*ome*/ reason++ /* incoherence */
#define plus /* smileys like these: "^x^"*/" ^"/*<_> /\ <_>*/
/*are*/ int/*erpreted*/ when(int/*ense and*/ profuse,
/* as un*/int/*elligent*/ rantings) {/*of*/
return/*ing*/ 0/*s.*/;}
/*Those "rantings", like the white*/ char/*coal*/ *they(
char/*acterise, are*/ *real/*ly the*/){/*insights of
coders*/ return/*ed*/ /*from a higher*/ real/*ity*/;}
/*They seek to*/ int/*erpret and inform us*/
of_more_appropriate_sources(/* of C knowledge that*/
short/*ly they will make*/ available){/*to those who*/
return /*their copy of the standard. A $*/30;} /*refund
will be*/ post/*ed to those who*/ *learn, /* that to be */
*ignorant="of the standard"; /* is not the */
#define end "\nT"/*o*/ w/*homever insults their*/
int/*elligence and */ reason/* they may retort
that -1*/=-1;
/* Such profundity will remain */ long /*after*/
what/*ever benefit your safety initialisor i*/=0;
char/*ried to the*/ newsgroups[1]; /* Maintain */int/*erest
in their wisdom - */ my_guess, /* is */ more; /* posts of
larger*/ size_t/*o spread the message of the new breed*/
like /* it deserves to be - */ = /* to the*/ sizeof( /* the
heart of the most intrepid of lurkers in the */
newsgroups);
#define /* a heart that*/ questions stdin/*terpretations of */
float/*ing point comparisons, seeks the */ website/*s*/,
where, better /*than*/, textbook, /*knowledge accretes*/
then, asking /*only if the*/ =9; /*lives of a cat are
enough to in*/struct {/*the unin*/struct/*able*/ {
char/*ts the */ c;} l/*anguage to*/;} c/*limactic
heights*/={{'1'}}; /*The*/ struct/*ures unleashed by the
new breed will be of*/ {/*indes*/struct/*able*/
{/*ma*/int/*enance-free*/ Q/*uality*/;} A/*ssured not
to*/;} F/*ail. Free*/;
#define from /*all*/ break/*ages*/;
/*The*/ post/*ed*/ code[] /*as a string is*/ =
"int i=-3,j=2,k=0,m;\n" \
"m=++i;&&++j||++k;\n" \
plus \
"\nprintf (\"%d %d %d %d\",i,j,k,m);\n" \
end;
size_t as=sizeof(code);
/* Reading the code below should explain the problem.
*/
#define your (char*)/*acter*/ /* differently */
#define such (char/*acter*/*)/* as capable of independently */
/*learning the*/ int/*egral and*/ main(/*concepts of C programming,
A*/void){ int/*eracting before*/ you=1/*st observe the forum.*/;
for (what; reason;s) do {you; fwrite(such code, as, you, did)?
my_guess: trolling || new && naive;}
while (many(learn, by, fread(newsgroups,
like, c.l.c && asking, questions)));
if (they((post*) code) == your code)
for (better; they(learn); more) from else where;
then; return when(!they(ignorant),
of_more_appropriate_sources
(F.A.Q || textbook || website));}