multiple updates in for statement 
July 22nd, 2005, 12:24 PM
| | | |
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 | 
July 22nd, 2005, 12:24 PM
| | | | re: multiple updates in for statement
"Michael" <slick_mick_00@hotmail.com> wrote in message
news:c8l58l$3n2$1@hercules.btinternet.com...[color=blue]
> 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
>[/color]
I don't see anything wrong with what you've posted. What happens when you
compile/run it?
john | 
July 22nd, 2005, 12:24 PM
| | | | re: multiple updates in for statement
Michael wrote:
[color=blue]
> Ok how do i implement:
>
> #define MYCONST 10
>
> for(int i=0;i<MYCONST;i++,j--)
> {
> }[/color]
Your implementation is right.
I do not understand what are you asking...
- Dario | 
July 22nd, 2005, 12:24 PM
| | | | re: multiple updates in for statement
"Michael" <slick_mick_00@hotmail.com> wrote in message
news:c8l58l$3n2$1@hercules.btinternet.com...[color=blue]
> 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.[/color]
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 | 
July 22nd, 2005, 12:24 PM
| | | | re: multiple updates in for statement
Michael wrote:
[color=blue]
> 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.[/color]
Is the problem you forgot to declare and initialize "j"?
#define MYCONST 10
int j = ???;
for(int i=0;i<MYCONST;i++,j--)
{
} | 
July 22nd, 2005, 12:34 PM
| | | | re: multiple updates in for statement
In message <c8le09$1av2$1@news.rchland.ibm.com>, Bill Seurer
<seurer@us.ibm.com> writes[color=blue]
>Michael wrote:
>[color=green]
>> 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.[/color]
>
>Is the problem you forgot to declare and initialize "j"?[/color]
No (well, maybe), but as posted there's a missing comma between i++ and
j--.
--
Richard Herring | 
July 22nd, 2005, 12:34 PM
| | | | re: multiple updates in for statement
Richard Herring wrote:[color=blue]
> In message <c8le09$1av2$1@news.rchland.ibm.com>, Bill Seurer
> <seurer@us.ibm.com> writes
>[color=green]
>> Michael wrote:
>>[color=darkred]
>>> 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.[/color]
>>
>>
>> Is the problem you forgot to declare and initialize "j"?[/color]
>
>
> No (well, maybe), but as posted there's a missing comma between i++ and
> j--.[/color]
Huh? | 
July 22nd, 2005, 12:34 PM
| | | | re: multiple updates in for statement
Richard Herring wrote:[color=blue]
> In message <c8le09$1av2$1@news.rchland.ibm.com>, Bill Seurer
> <seurer@us.ibm.com> writes
>[color=green]
>> Michael wrote:
>>[color=darkred]
>>> 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.[/color]
>>
>>
>> Is the problem you forgot to declare and initialize "j"?[/color]
>
>
> No (well, maybe), but as posted there's a missing comma between i++ and
> j--.[/color]
Eh... Huh? Do you think there are supposed to be two commas? | 
July 22nd, 2005, 12:34 PM
| | | | re: multiple updates in for statement
In message <u-2dnUyJ5qSjjivd4p2dnA@comcast.com>, Jeff Schwab
<jeffplus@comcast.net> writes[color=blue]
>Richard Herring wrote:[color=green]
>> In message <c8le09$1av2$1@news.rchland.ibm.com>, Bill Seurer
>><seurer@us.ibm.com> writes
>>[color=darkred]
>>> 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"?[/color]
>> No (well, maybe), but as posted there's a missing comma between i++
>>and j--.[/color]
>
>Eh... Huh? Do you think there are supposed to be two commas?[/color]
See my reply to VB :-(
--
Richard Herring | 
July 22nd, 2005, 12:35 PM
| | | | re: multiple updates in for statement
In message <Jmotc.672$ri.59536@dfw-read.news.verio.net>, Victor Bazarov
<v.Abazarov@comAcast.net> writes[color=blue]
>Richard Herring wrote:[color=green]
>> In message <c8le09$1av2$1@news.rchland.ibm.com>, Bill Seurer
>><seurer@us.ibm.com> writes
>>[color=darkred]
>>> 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"?[/color]
>> No (well, maybe), but as posted there's a missing comma between i++
>>and j--.[/color]
>
>Huh?[/color]
Sorry, I take it back. This stupid sans-serif font runs the comma
indistinguishably into the j :-(
--
Richard Herring |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,702 network members.
|