Cracked Ceiling Repair

How can I repair cracks in a ceiling?  I’m about to repaint a room, and want to make sure the ceilings will not crack again after I complete the painting project.