The inclusive production of D*+- mesons in photon-photon collisions has been measured using the OPAL detector at LEP at e+e- centre-of-mass energies of 183 and 189GeV. The D* mesons are reconstructed in their decay to D0pi+ with the D0 observed in the two decay modes Kpi+ and Kpi+pi-pi+. After background subtraction, 100.4+-12.6(stat) D*+- mesons have been selected in events without observed scattered beam electron ("anti-tagged") and 29.8+-5.9 (stat) D*+- mesons in events where one beam electron is scattered into the detector ("single-tagged"). Direct and single-resolved events are studied separately. Differential cross-sections as functions of the D* transverse momentum p_t and pseudorapidity \eta are presented in the kinematic region 2<p_t<12GeV and \eta<1.5. They are compared to next-to-leading order (NLO) perturbative QCD calculations. The total cross-section for the process (e+e- to e+e-ccbar), where the charm quarks are produced in the collision of two quasi-real photons, is measured to be 842+-97(stat)+-75(syst)+-196(extrapolation)pb. A first measurement of the charm structure function F2 of the photon is performed in the kinematic range 0.0014<x<0.87 and 5<Q^2<100 GeV^2, and the result is compared to a NLO perturbative QCD calculation.