quick question about "++"

M

mdh

Given the expression:

while (isaspace(c = *s++))
x+1;
(s is an array)

Does the increment to 's' occur after "x+1" is evaluated, or after
the content of s is assigned to c? Is there a general rule as to when
this type of increment occurs? ( I understand that the increment in "c
= ++*s" occurs immediately before assignment, so my guess is the same
would apply in the "after" scenerio, but not sure).

thank you.
 
U

user923005

Given the expression:

while (isaspace(c = *s++))
x+1;
(s is an array)

Does the increment to 's' occur after "x+1" is evaluated, or after
the content of s is assigned to c? Is there a general rule as to when
this type of increment occurs? ( I understand that the increment in "c
= ++*s" occurs immediately before assignment, so my guess is the same
would apply in the "after" scenerio, but not sure).

It's a FAQ:

4.3: Does *p++ increment p, or what it points to?

A: Postfix ++ essentially has higher precedence than the prefix
unary operators. Therefore, *p++ is equivalent to *(p++); it
increments p, and returns the value which p pointed to before
p
was incremented. To increment the value pointed to by p, use
(*p)++ (or perhaps ++*p, if the order of the side effect
doesn't
matter).

References: K&R1 Sec. 5.1 p. 91; K&R2 Sec. 5.1 p. 95; ISO
Sec. 6.3.2, Sec. 6.3.3; H&S Sec. 7.4.4 pp. 192-3, Sec. 7.5 p.
193, Secs. 7.5.7,7.5.8 pp. 199-200.
 
E

Eric Sosman

mdh said:
Given the expression:

while (isaspace(c = *s++))
x+1;
(s is an array)

Therefore, a diagnostic is required. Please -- PLEASE! --
study Section 6 of the comp.lang.c Frequently Asked Questions
(FAQ) list at http://c-faq.com/ before posting such nonsense
again. (Or "again-again," as it seems you are a repeat offender.)
Does the increment to 's' occur after "x+1" is evaluated, or after
the content of s is assigned to c?

If `s' were incrementable (which you say it is not), it
would be incremented before `x+1' is evaluated, and at some
indeterminate time with respect to the assignment of a new
value to `c'.
Is there a general rule as to when
this type of increment occurs?

Yes: At some unspecified time after the preceding sequence
point and before the following sequence point.
( I understand that the increment in "c
= ++*s" occurs immediately before assignment, so my guess is the same
would apply in the "after" scenerio, but not sure).

You might just as well "understand" that the Moon is made
of green cheese. There is *no* temporal relationship between
the incrementing of `*s' and the assignment of a new value to
`c'. Both occur after the preceding sequence point and before
the next sequence point, but they may occur in any order with
respect to each other -- even simultaneously or overlapped in
time so the notions of "before" and "after" are meaningless.
If you "understand" some more specific ordering, your thoughts
are of phantasms and chimeras.
 
M

mdh

Therefore, a diagnostic is required. Please -- PLEASE! --
study Section 6 of the comp.lang.c Frequently Asked Questions
(FAQ) list athttp://c-faq.com/before posting such nonsense
again.
of green cheese. There is *no* temporal relationship between
the incrementing of `*s' and the assignment of a new value to
`c'.

Eric, I am not about to bite the hand that feeds me, but I DO look at
the FAQs but nowhere did I get a great explanation of the real issue
that was causing the problem to come up.....ie the fact that
*temporal relationships* play no role. Sometimes asking what some
might consider an obviously erroneous idea, may not be that obvious to
the poster. I try and post what I think not because I want to show how
smart/dumb I am, but I have seen enough to know that questions like
"Teach me about ++" ( and do my assignment) gets an even greater
vociferous response from the clc.

Anyway, thanks for your input and apologies that this was asked
twice, for which I have to point a finger at Google, which has
recently, once again been on the fritz ( which means there is most
definitely a * temporal* relationship between posting and seeing one's
message.
 
C

Clark Cox

Given the expression:

while (isaspace(c = *s++))
x+1;
(s is an array)

Does the increment to 's' occur after "x+1" is evaluated, or after
the content of s is assigned to c? Is there a general rule as to when
this type of increment occurs? ( I understand that the increment in "c
= ++*s" occurs immediately before assignment, so my guess is the same
would apply in the "after" scenerio, but not sure).

thank you.

You already asked this 2 days ago. Go read the responses you got then.
 
J

Jack Klein

Given the expression:

while (isaspace(c = *s++))
x+1;
(s is an array)

Does the increment to 's' occur after "x+1" is evaluated, or after
the content of s is assigned to c? Is there a general rule as to when
this type of increment occurs? ( I understand that the increment in "c
= ++*s" occurs immediately before assignment, so my guess is the same
would apply in the "after" scenerio, but not sure).

thank you.

Did you even read the answers you received to the same question two
days ago?

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/
alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
 
M

mdh

Did you even read the answers you received to the same question two
days ago?

Google...google...google.

Sorry...as I said, above, but not even sure if this is being sent
through, so I will repeat it..

....... apologies that this was asked
twice, for which I have to point a finger at Google, which has
recently, once again been on the fritz ( which means there is most
definitely a * temporal* relationship between posting and seeing
one's
message.
 
C

CBFalconer

mdh said:
.... snip ...

Anyway, thanks for your input and apologies that this was asked
twice, for which I have to point a finger at Google, which has
recently, once again been on the fritz ( which means there is
most definitely a * temporal* relationship between posting and
seeing one's message.

So get rid of google and use a newsreader and server. Thunderbird
(from mozilla.com) meets the first, and if your ISP doesn't supply
a news server see below.

--
Some free news servers. I use teranews and gmane.
<http://www.teranews.com> (1 time charge) (free)
<http://news.aioe.org> (free)
<http://dotsrc.org> (free)
<http://www.x-privat.org/international.php> (free)
<http://motzarella.org/?language=en> (free)
<http://gmane.org/> (mail-lists via news) (free)
<http://www.newsfeeds.com/signup.htm> (pay)
<http://www.individual.net/ (low pay)
 
R

Richard Heathfield

Clark Cox said:

You already asked this 2 days ago. Go read the responses you got then.

Folks, we KNOW Google is on the blink again. Can we cut people a little
slack, please, until it's sorted out?
 
C

Clark Cox

Clark Cox said:



Folks, we KNOW Google is on the blink again. Can we cut people a little
slack, please, until it's sorted out?

All of the Google-induced repeats that I had seen up to this point were
separated in time by minutes and hours, not days.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top