Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

C Programming Language

quick question about "++"


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.

On May 31, 7:29 pm, mdh <m@comcast.net> wrote:

> 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.

mdh wrote:
> 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.

--
Eric Sosman
esos@acm-dot-org.invalid

On May 31, 8:10 pm, Eric Sosman <esos@acm-dot-org.invalid> wrote:


     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.

>  >      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'.

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.

On 2007-05-31 19:29:30 -0700, mdh <m@comcast.net> said:

> 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.

--
Clark S. Cox III
clarkc@gmail.com

On 31 May 2007 19:29:30 -0700, mdh <m@comcast.net> wrote in
comp.lang.c:

> 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

> > thank you.

> 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.

mdh wrote:

... 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)

--
Posted via a free Usenet account from http://www.teranews.com

Clark Cox said:

<snip>

> 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?

--
Richard Heathfield
"Usenet is a strange place" - dmr 29/7/1999
http://www.cpax.org.uk
email: rjh at the above domain, - www.

On 2007-06-01 02:53:47 -0700, Richard Heathfield <r@see.sig.invalid> said:

> Clark Cox said:

> <snip>

>> 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?

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

--
Clark S. Cox III
clarkc@gmail.com

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc