  This review is devoted to the study of charm production in ep and pp
collisions. The total set of measurements obtained by the two collaborations H1
and ZEUS from HERA and their combination is outlined, as well as complementary
data obtained by the LHCb collaboration at the LHC. After fitting the parton
distribution functions the charm production cross sections are predicted within
perturbative QCD at next-to-leading order using the fixed-flavour-number
scheme. Agreement with the data is found. The combined HERA charm data are
sensitive to the $c$-quark mass and enabled its accurate determination. The
predictions crucially depend upon the knowledge of the gluon distribution
function. It is shown that the shape of the gluon distribution based on the
HERA data is considerably improved by adding the measurements from LHCb and
applicable down to values x of about 10^{-6}, where x is the proton momentum
fraction carried by a parton.
