By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,804 Members | 1,634 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,804 IT Pros & Developers. It's quick & easy.

multiple updates in for statement

P: n/a
Ok how do i implement:

#define MYCONST 10

for(int i=0;i<MYCONST;i++,j--)
{
}

that is I want two items in the last part of the for statement.
Thanks
Mike
Jul 22 '05 #1
Share this Question
Share on Google+
9 Replies


P: n/a

"Michael" <sl***********@hotmail.com> wrote in message
news:c8**********@hercules.btinternet.com...
Ok how do i implement:

#define MYCONST 10

for(int i=0;i<MYCONST;i++,j--)
{
}

that is I want two items in the last part of the for statement.
Thanks
Mike


I don't see anything wrong with what you've posted. What happens when you
compile/run it?

john
Jul 22 '05 #2

P: n/a
Michael wrote:
Ok how do i implement:

#define MYCONST 10

for(int i=0;i<MYCONST;i++,j--)
{
}


Your implementation is right.
I do not understand what are you asking...

- Dario
Jul 22 '05 #3

P: n/a

"Michael" <sl***********@hotmail.com> wrote in message
news:c8**********@hercules.btinternet.com...
Ok how do i implement:

#define MYCONST 10

for(int i=0;i<MYCONST;i++,j--)
{
}

that is I want two items in the last part of the for statement.


Assuming j is defined somewhere, you're fine as is. If not how about:

for( int i = 0, j = MYCONST ; i != MYCONST ; ++i, --j )
{
}

Jeff F
Jul 22 '05 #4

P: n/a
Michael wrote:
Ok how do i implement:

#define MYCONST 10

for(int i=0;i<MYCONST;i++,j--)
{
}

that is I want two items in the last part of the for statement.


Is the problem you forgot to declare and initialize "j"?
#define MYCONST 10

int j = ???;

for(int i=0;i<MYCONST;i++,j--)
{
}
Jul 22 '05 #5

P: n/a
In message <c8***********@news.rchland.ibm.com>, Bill Seurer
<se****@us.ibm.com> writes
Michael wrote:
Ok how do i implement:
#define MYCONST 10
for(int i=0;i<MYCONST;i++,j--)
{
}
that is I want two items in the last part of the for statement.


Is the problem you forgot to declare and initialize "j"?


No (well, maybe), but as posted there's a missing comma between i++ and
j--.
--
Richard Herring
Jul 22 '05 #6

P: n/a
Richard Herring wrote:
In message <c8***********@news.rchland.ibm.com>, Bill Seurer
<se****@us.ibm.com> writes
Michael wrote:
Ok how do i implement:
#define MYCONST 10
for(int i=0;i<MYCONST;i++,j--)
{
}
that is I want two items in the last part of the for statement.

Is the problem you forgot to declare and initialize "j"?

No (well, maybe), but as posted there's a missing comma between i++ and
j--.


Huh?
Jul 22 '05 #7

P: n/a
Richard Herring wrote:
In message <c8***********@news.rchland.ibm.com>, Bill Seurer
<se****@us.ibm.com> writes
Michael wrote:
Ok how do i implement:
#define MYCONST 10
for(int i=0;i<MYCONST;i++,j--)
{
}
that is I want two items in the last part of the for statement.

Is the problem you forgot to declare and initialize "j"?

No (well, maybe), but as posted there's a missing comma between i++ and
j--.


Eh... Huh? Do you think there are supposed to be two commas?
Jul 22 '05 #8

P: n/a
In message <u-********************@comcast.com>, Jeff Schwab
<je******@comcast.net> writes
Richard Herring wrote:
In message <c8***********@news.rchland.ibm.com>, Bill Seurer
<se****@us.ibm.com> writes
Michael wrote:

Ok how do i implement:
#define MYCONST 10
for(int i=0;i<MYCONST;i++,j--)
{
}
that is I want two items in the last part of the for statement.
Is the problem you forgot to declare and initialize "j"?

No (well, maybe), but as posted there's a missing comma between i++
and j--.


Eh... Huh? Do you think there are supposed to be two commas?


See my reply to VB :-(

--
Richard Herring
Jul 22 '05 #9

P: n/a
In message <Jm****************@dfw-read.news.verio.net>, Victor Bazarov
<v.********@comAcast.net> writes
Richard Herring wrote:
In message <c8***********@news.rchland.ibm.com>, Bill Seurer
<se****@us.ibm.com> writes
Michael wrote:

Ok how do i implement:
#define MYCONST 10
for(int i=0;i<MYCONST;i++,j--)
{
}
that is I want two items in the last part of the for statement.
Is the problem you forgot to declare and initialize "j"?

No (well, maybe), but as posted there's a missing comma between i++
and j--.


Huh?


Sorry, I take it back. This stupid sans-serif font runs the comma
indistinguishably into the j :-(

--
Richard Herring
Jul 22 '05 #10

This discussion thread is closed

Replies have been disabled for this discussion.