Carbon can be produced in stars at least as massive as the Sun by fusion of three helium-4 nuclei: He + He + He --> C. This is the triple alpha process.
In stars as massive as the Sun, carbon 12 is also converted to carbon 13 and then onto nitrogen 14 by fusion with protons. C + H --> C + e. C + H --> N. In more massive stars, two carbon nuclei can fuse to magnesium, or a carbon and an oxygen to sulfur.