W
Waxhead
Hi folks, First of all I'm new to newsgroups so please don't kill me in
case I'm breaking any rules , but if you really have to make it quick
and painfull
What is actually propper hehaviour of Snippet 1 ? as I understand it
the result should be the same as snippet 2. (but it isn't at least with
my compiler).
I expect snippet 1 to work like this: if then for and function() else
just function() or perhaps a bit clearer:
if A is false C get's executed once
if A is true do B and execute C repeatedly while n<step
Snippet 2 is working as it should. but I tried to avoid having two
functioncalls by rewriting as in snippet 1 and now I'm confused... :/
/*** Snippet 1 ***/
for(int x=0; x<xwidth ; x++)
{
for(int y=0; y<ywidth ; y+=step)
{
if(0==(x%step)) /* A */
for(int n=0;n<step;n++) /* B */
SetPixel(hdc,x,y,gridcolor); /* C */
}
}
/*** Snippet 2 ***/
for(int x=0; x<xwidth ; x++)
{
for(int y=0; y<ywidth ; y+=step)
{
SetPixel(hdc,x,y,gridcolor);
if(0==(x%step)) /* D */
{
for(int n=0;n<step;n++) /* E */
SetPixel(hdc,x,y+n,gridcolor); /* F */
}
}
case I'm breaking any rules , but if you really have to make it quick
and painfull
What is actually propper hehaviour of Snippet 1 ? as I understand it
the result should be the same as snippet 2. (but it isn't at least with
my compiler).
I expect snippet 1 to work like this: if then for and function() else
just function() or perhaps a bit clearer:
if A is false C get's executed once
if A is true do B and execute C repeatedly while n<step
Snippet 2 is working as it should. but I tried to avoid having two
functioncalls by rewriting as in snippet 1 and now I'm confused... :/
/*** Snippet 1 ***/
for(int x=0; x<xwidth ; x++)
{
for(int y=0; y<ywidth ; y+=step)
{
if(0==(x%step)) /* A */
for(int n=0;n<step;n++) /* B */
SetPixel(hdc,x,y,gridcolor); /* C */
}
}
/*** Snippet 2 ***/
for(int x=0; x<xwidth ; x++)
{
for(int y=0; y<ywidth ; y+=step)
{
SetPixel(hdc,x,y,gridcolor);
if(0==(x%step)) /* D */
{
for(int n=0;n<step;n++) /* E */
SetPixel(hdc,x,y+n,gridcolor); /* F */
}
}