I assume loop() is a function - define your for() control variable as static and it will remember the last value
Code:
void loop()
{
static int n=0;
for (; n<10; n++)
{
if (n==5) { i++; return; }
//code lines
//code lines
//code lines
}
}
on first call to loop() n would be 0 - next time loop() is called n will be 6
what happens when n becomes 10? every time the function is called n will be 10 and the for() not executed
not sure why you would wish to do this???
You probably has not figured out a correct way to solve your problem and ask strange questions...
The is also the setjmp.h with its functions/structures that save and restore execution states.
This is working for me, actually I am using this as a part of my code for a microcontroller, the for loop variable is used as an index for an array in a restrict timing regulation, anyway when the value reaches 10 I can reset it then in an other part.
Code:
if (cnt!=0 && Error<0)
{
cnt--; pattern >>= 1;
for ( n = 0; n <MASK_SIZE; n++)
{
dc_mask = masks [n];
break;
}
}