As I've stated before if you're buying a house, or looking to buy a house soon, you need to get a home inspection. If you haven't bought a house before I'll break down the steps for you here. Once you find a home you're willing to purchase, you put an offer in with an inspection contingency clause. This allows you to hire (at your expense-typically $350-500) an inspector to evaluate the home you're purchasing for any problems. Typically, inspections happen with 7-10 days of an accepted agreement. It is encouraged that you are there for the inspection. You can tag along with the inspector and go wherever he goes, ask questions, and he can explain what he's looking at. It usually lasts about 2-3 hours. They will provide you with a written report evaluating every area of the home, including, structure, roofing, exterior, plumbing, electrical, heating, air conditioning, interior, insulation and ventilation, and fireplaces. An inspector will explain to you what needs immediate attention, and what may be a problem down the road.
If there are any problems found in the inspection there will usually be additional negotiation between you and the seller (well, me and their agent). If it turns out that the roof is in danger of falling off any second, you may want to ask for the seller to fix the roof asap. However, you can also split the cost, negotiate the repairs off the price of the house, or ask for a credit towards closing. Typically minor fixes such as door knobs that need replacing, etc are not something you negotiate on. Save it for the big ticket fixes like roofing, plumbing, heating, and structural.
Now, if you decide that the list of fixes is too big or too expensive you can cancel the agreement. You will not get back the $400 you spent for the home inspection but you won't have to shell out $5,000 for a new roof if you bought the house without an inspection. It's well worth the cost.
You can find an inspector by going to the American Society of Home Inspectors (ASHI), or asking your realtor for suggestions.