You get a survey. Last time if did, there were three sorts:
Mortgage valuation - carried out by your mortgage co. To check it's worth what they're lending (remember, that's all they need to get back, not the full price you pay, though they'll give a total value in their report). Simplest sort of survey.
Homebuyer's report - standard survey, you pay for it.
Building Survey - this is what structural surveys are called now. More in depth than a homebuyers, done by surveyors with a higher standard of training. Useful for older and unusual houses or where you suspect there's a structural issue.
Two important points:
Part of the reason for paying for a survey is that you have a contractual relationship with the surveyor. They are regulated and insured. If they make a big mistake you can sue them and hope to get a settlement that pays for rectifying the issue they missed.
If the survey recommends that you check something - state of roof, cost of re-wiring etc, check it. Get a few quotes before purchase so you know what you're facing. Surveyors cannot see everything e.g. They don't climb onto roofs or pull up floors but they can spot clues that things might be amiss. If they're telling you to get something checked, it's because they've spotted something, they don't know how far amiss it might be and, if far, it could be expensive, so you must find out. You have no comeback if they told you to check and you don't.