difference between static and volatile variable

Hi
could someone please explain the difference between static and volatile variables please and when to use each. I'm looking to define a few variables for time inside a function and don't want to lose there values between calls to the function.
Thanks
Don

Static variables retain their value between function calls.

Volatile variables (which is not the opposite of static) are used when a variable is used both within an ISR (interrupt service routine) and outside it.

The opposite of static is really "auto". eg.

void foo ()
  {
  auto int i;
  }

However since auto is implied, most programmers leave it off, eg.

void foo ()
  {
  int i;
  }

In both cases the variable "i" does not retain its value from one call of foo to the next.

Nick
Thank you for the explanation of that.
Don

Note that the "auto" keyword is changing meaning, so that a variable is automatically given the data type of its initialiser, I guess because the old usage was redundant.