I am very much an amateur with all things programming related so I am curious about the normal use of the static keyword when declaring a variable. I have slightly more experience programming with avrstudio in C whereby in my main function I will first declare my variables and then use a 'while' loop to cycle through my code that actually has action items. I notice that the equivalent process in arduino is to declare my variables all as static to avoid having the loop function create and initialize them on each iteration through my loop. Is this pretty typical to declare all variables in loop as static if you don't want to reinitialize them every time? For example it seems that:
void main()
{
int i = 0;
int j = 10;
while(1)
{
i++;
j--;
}
}
is not equivalent to:
void loop()
{
int i = 0;
int j = 10;
i++;
j--;
}
but is equivalent to:
void loop()
{
static int i = 0;
static int j = 10;
i++;
j--;
}