What happens at the end of a x++ function

Hi Guys,
I am trying to make one button cycle thru 3 leds then when pressed a 4th time it goes back to one.
Is there a registry reset or something similar ?
BlackSnake

You mean something like this?

pseudo code

if (buttonPressed() == true)
{
  switchOff(x);
  x++;
  if (x>3) x = 0;
  switchOn(x);
}