Americans are notorious for racking up credit-card debt, but new data from CreditCards.com reveals a frightening statistic: A good 39 million Americans have been carrying credit-card debt for at least two years. Meanwhile, 14% of folks with credit-card debt have been carrying a balance for at least five years, while 7% can't even remember how long they've been in debt.

When we think of the reasons why people might end up with credit-card debt, it's easy to point a finger at impulse shopping. But actually, more than a third of U.S. adults attribute their credit-card debt to emergencies -- 14% cite car repairs, 12% blame medical bills, and 9% chalk it up to home repairs.

If you'd rather not join the ranks of the millions of Americans who are carrying credit-card debt for the long haul, you must take steps to build an emergency fund. Otherwise, you're likely to wind up in the same boat, and your finances might really suffer for it.

Couple looking at laptop; man has confused expression and woman holds a credit card.

IMAGE SOURCE: GETTY IMAGES.

You need that safety net

Without emergency savings, you're bound to have no choice but to whip out a credit card the next time an unplanned expense hits you out of the blue. The problem there, of course, is that the longer you carry that balance, the more interest you rack up and the more that original expense ends up costing you. At the same time, holding too much credit card debt can bring down your credit score, making it more difficult for you to borrow money affordably should the need arise. Therefore, if you're starting with little to no savings, start making lifestyle changes that allow you to build a true emergency fund -- one with three to six months' worth of living expenses to cover unplanned bills or an unexpected period of unemployment.

To start, create a budget, which will show you where your paycheck goes month after month and where there's room to cut back on spending. Once you have that budget in place, you can decide which expense categories to reduce in order to free up cash to save. You might choose to cancel cable, downgrade your data plan, and stop dining out. Or you might decide to give up the car you enjoy having but technically don't need. The choice is yours, but the key is to make meaningful spending cuts so that you're able to boost your personal cash reserves in a relatively short time frame. (Keep in mind that you're not expected to build your emergency fund overnight -- but saving up three months of living costs over the course of a year isn't totally unreasonable.)

Another good way to build emergency savings? Get yourself a side hustle in addition to your regular job. Spending a few evenings a week or a few weekends a month earning money could put enough extra cash in your pocket to make real progress on that safety net. And if you're able to turn a hobby you enjoy into a money-making opportunity, even better -- that way, it won't actually feel like work.

Finally, if you're without solid emergency savings, send any extra cash that comes your way directly into the bank. That could mean stashing away your tax refund, a bonus at work, or the cash back you get from the credit card you're dangerously close to abusing.

The fact that so many Americans blame emergency expenses for their credit card debt highlights the need for money in the bank. If your emergency fund needs work, make that your highest priority -- before an unplanned bill drives you into debt and upends your finances in the process.