ppl,
I want to wrap around in a array. I now use this code but I would like
to start at position 3 and end at position 2. It needs to be something with modulo but I can't figure out how. Keep in mind that pos is a variable that
gets changed just like the board, this is only a simplified version of a function I use.
I've seen something like this with a for loop around itCode:#include <stdio.h> int main ( void ) { int board[] = {9, 8, 6, 3, 4, 1, 3, 5, 2}; int pos = 3; int i; for ( i = 0; i < 10; i++ ) if (pos == i) continue; else if (board[i] == board[pos]) printf ( "%d same wrong \n", board[i] ); //return true to use in other part of the program return 0; }
printf ( "%d ", a[i % 9] );
But i would like to use it in a for loop so it don't start at zero but at pos & wraps around.