increment in blocks of 100 in for loop?

Hi,

How do you increment in blocks of 100 in a for loop?

I tried the code below but ‘s’ is always printed as zero.

Thanks

  myFile = SD.open("test.text");
  int sizefile = myFile.size();
  Serial.println(sizefile);

if (myFile)
  {
    for(int s = 0; s < myFile.size(); s+100){
     Serial.println(s);
     delay(2000);
     myFile.seek(s);
    }
for(int s = 0; s < myFile.size(); s+=100){

And to extend on AWOL. s+100 just gives you a new variable that’s 100 higher then s. But you never assign it to anything. So to increment s itself you should assign it to s again so s = s + 100. That way the new variable of 100 higher then s is assigned to s. But because we often want to change a variable in a way like that the made a shorter notation, s += 100 which is the same as s = s + 100. You also have -=, /=, *=, <<=, %= etc. So without a = somewhere (is it by using += or by doing s = s + 100) you never change the variable itself but you create a new variable with the changed value. But without a = it’s destroyed right after that (or probably optimized away by the compiler :stuck_out_tongue: )

I hate double post. http://forum.arduino.cc/index.php?topic=381690.msg2631524#msg2631524