# How to decrement a variable in every line of a loop..?

**URL:** <https://forum.arduino.cc/t/how-to-decrement-a-variable-in-every-line-of-a-loop/1265739>\
**Category:** Programming\
**Created:** [May 29, 2024, 6:55pm UTC](https://forum.arduino.cc/t/how-to-decrement-a-variable-in-every-line-of-a-loop/1265739 "2024-05-29T18:55:14Z")\
**Posts on this page:** 1\
**Showing post:** 34

<div class="post-metadata">

**Author:** ![DaveX](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/davex/32/751443_2.png) [@DaveX](https://forum.arduino.cc/u/DaveX)\
**Post date:** [May 30, 2024, 12:50pm UTC](https://forum.arduino.cc/t/how-to-decrement-a-variable-in-every-line-of-a-loop/1265739/34 "2024-05-30T12:50:07Z")

</div>

Those lines are full of patterns.

You should look into [arrays](https://www.arduino.cc/reference/en/language/variables/data-types/array/) and [structures](https://www.tutorialspoint.com/cprogramming/c_structures.htm), the magic combination of arrays of struct, and the [https://docs.arduino.cc/learn/built-in-libraries/eeprom/](https://docs.arduino.cc/learn/built-in-libraries/eeprom/) EEPROM.put() and EEPROM.get() commands that can read/write (and update) a whole table worth of information in one line like these:

```
EEPROM.get(333,dayDates);
dayDates[7].date = 22; 
EEPROM.put(333,dayDates); 

EEPROM.get(93,onOffSchedule);
onOffSchedule[7][1] = 6;
EEPROM.put(93,onOffSchedule);

EEPROM.get(33,activeBits)
Serial.print(activeBits[7][4];

EEPROM.get(1,regularSchedule);
Serial.print(regularSchedule[0].morning_hour_off);
...

```

As for arrays of structs, the [Flashing multiple LEDs at the same time](https://forum.arduino.cc/t/flashing-multiple-leds-at-the-same-time/1065564) tutorial has several examples of using arrays of structs to extend the BlinkWithoutDelay example to multiple blinking LEDs.

I'm sad that [https://docs.arduino.cc/programming/](https://docs.arduino.cc/programming/) doesn't mention ['`struct'`](https://en.cppreference.com/w/c/language/struct), and [array - Arduino Reference](https://www.arduino.cc/reference/en/language/variables/data-types/array/) doesn't even hint at, and almost discourages arrays of structs.

---

_[View the full topic](https://forum.arduino.cc/t/how-to-decrement-a-variable-in-every-line-of-a-loop/1265739)._
