[A89] c code problem...


[Prev][Next][Index][Thread]

[A89] c code problem...




What is the difference betweent these two snippets of code? That is, why
doesn't the while loop output the same thing as the for loop?

for((*count)=1; (*count)<=52+8; (*count)++) // loop no more than 60 times
{
    if(cards_placed[(*count)]==0)  // if we've come to the end of the stack
        (*zero)++;          // increment the counter
    if((*zero)==tempx)       // if we have looped enough
        break;            // break out of the loop
    if((cards_placed[(*count)]==0) && ((*zero)!=tempx)) // if we finished
the stack
        (*py)=-2;           // reset the y coordinate variable
    (*py)++;            // increase it
}

...and...

(*count)=1;
while((*zero)!=tempx)
{
    if(cards_placed[(*count)]==0)
        (*zero)++;
    if((cards_placed[(*count)]==0) && ((*zero)!=tempx))
        (*py)=-2;
    (*py)++;
   (*count)++;
  }

Thanks...






Follow-Ups: References: