The evolution of carbon stars in the Magellanic Clouds.