We present a model atom for C i–C ii–C iii–C iv using the most up-to-date atomic data and evaluated the non-local thermodynamic equilibrium line formation in classical 1D atmospheric models of O-B-type stars. Our models predict the emission lines of C ii 9903 Å and 18,535 Å to appear at effective temperature Teff ≥ 17,500 K, those of C ii 6151 Å and 6461 Å to appear at Teff > 25,000 K, and those of C iii 5695, 6728–44 and 9701–17 Å to appear at Teff ≥ 35,000 K (log g = 4.0). Emission occurs in the lines of minority species, where the photoionization-recombination mechanism provides a depopulation of the lower levels to a greater extent than the upper levels. For C ii 9903 and 18535 Å, the upper levels are mainly populated from the C iii reservoir through the Rydberg states. For C iii 5695 and 6728–44 Å, the lower levels are depopulated due to photon losses in UV transitions at 885, 1308, and 1426–28 Å, which become optically thin in the photosphere. We analyzed the lines of C i, C ii, C iii, and C iv for twenty-two O-B-type stars with temperature range between 15,800 ≤Teff ≤ 38,000 K. Abundances from emission lines of C i, C ii, and C iii are in agreement with those from absorption ones for most of the stars. We obtained log C = 8.36 ± 0.08 from twenty B-type stars, that is in line with the present-day Cosmic Abundance Standard. The obtained carbon abundances in 15 Mon and HD 42088 from emission and absorption lines are 8.27 ± 0.11 and 8.31 ± 0.11, respectively.