[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]

Re: i = i++



hi
firstly, my question was not i++ = i. i++ does not
return an lvalue as u rightly pointed out and it will
not even compile. my question was ++i = i ; as some
people rightly poited out, it operates on the same
variable more than once and hence is undefined. 

as far as the following is concerned

A operator ++ (int){a temp(num) ; num++ ; return temp}

i thought that this is the way postfix increment
works. id increments the value but returns an
anonymous variable having the previous. atleast that
is what i learnt. please let me know if is wrong!

sindhoor
> talking over here. a
> statement such as i++ = i is inherently absurd
> because i++ yields a value
> and not a pointer and thus no lvalue to accompalish
> assignment.
> 

i dont understan what this means ? are u trying to say
that only pointers can be on the left of an
assignment? then what about int i ; i = 10; please
clarify ! 




> correct me if need be.
> ----- Original Message -----
> From: "Amarendra GODBOLE"
> <amarg@xxxxxxxxxxxxxxxxxxxxx>
> To: <linux-india-programmers@xxxxxxxxxxxxxxxxxxxxx>
> Sent: Thursday, January 11, 2001 8:49 AM
> Subject: Re: [LIP] i = i++
> 
> 
> > On Wed, Jan 10, 2001, the greycells of P k j ~ c K
> expressed:
> >
> > > read some C faqs . they say  changing a variable
> in a statement which
> refers it twice isn't valid . so
> >
> > The question of valid or invalid does not figure
> out here. The fact is
> that, the ANSI standard says
> > nothing about such statements, these are called
> "statements with
> side-effects".
> > The outcome is not predictable, as EVERY compiler
> is free to implement it
> as it wishes.
> >
> > Essentially, K&R advises to avoid such statements
> with side effects. It is
> _NOT_ a good programming
> > practice at all.
> >
> > People administering C language tests should avoid
> asking such questions,
> as they make no sense. ;-)
> > (We have a tendency to make the C test as arcane
> as possible) ;-)
> >
> > > anything like
> > > ++i = i;  or
> > > ++i = i++;  or
> > > printf("%d %d",++i,i++);     are not valid &
> thus may differ from
> compiler to compiler
> >                                    ^^^^^^^^^
> > Cheers,
> > -amar-
> >
> > --
> > Amarendra GODBOLE (http://ag.dnsq.org)
> > Public Key: http://pubkey.dnsq.org
> > 18.97 deg. N / 72.83 deg. E
> > +0530 GMT
> >
> >
> >
> > ---------------------------------------------
> > Find out more about this and other Linux India
> > mailing lists at http://lists.linux-india.org/
> >
> 
> 
> ---------------------------------------------
> An alpha version of a web based tool to manage
> your subscription with this mailing list is at
> http://lists.linux-india.org/cgi-bin/mj_wwwusr


__________________________________________________
Do You Yahoo!?
Get email at your own domain with Yahoo! Mail. 
http://personal.mail.yahoo.com/