Get a home inspection, the peace of mind knowing that the home was given a proper home inspection by a professional is worth the small fees you pay for the service. A few hundred dollars can save you tens of thousands dollars if home inspection finds a bad roof or heating system.
Real estate agents will have home inspectors that they prefer working with. Also get recommendations from friends and family who are fellow homeowners.
The home inspector will go through every room (2-3 hours on average), note every concern that they come across and recommend repairs. At the end they will send you a typed report accompanied by photos and you can use the report to get the seller to fix the issues before selling the house to you, or use the report to negotiate prices adjustments.
Every sales contract should include a home inspection contingency allowing the buyer get out of the contract agreement if something serious is turned up during the home inspection.