Chances are high that you've had a Charley horse at some time in your life. No doubt it was painful, but did you ever wonder what causes those dang cramps and how you can avoid them? While the exact cause of muscle cramps remains a mystery, it is believed they come from overexertion and dehydration.
Weak muscles are more likely to get overexerted when exercising and this overexertion depletes the muscle of oxygen. Without oxygen, waste product builds up in the muscle causing the fibers to spasm and shorten the muscle. Keeping muscle fibers strong and long (this means stretching) helps them do their job much better. Yep, stretching is key.
Want to learn what else contributes to cramping? Then
Dehydration is a factor too. When you sweat you lose fluids, salt and minerals, aka electrolytes. Electrolytes are the minerals--calcium, magnesium and potassium which your muscles need to function. So drink before you are thirsty to avoid dehydration or try a sports drink that contains electrolytes.
When you do cramp up you should stop doing whatever activity triggered the cramp and gently stretch and massage the area. If the area is really painful you can try icing it too. But to add to the mystery of cramping, some people find heat helps more than ice.