We propose a simple method to estimate the central charge of the conformal field theory corresponding to a critical point of a two-dimensional lattice model from Monte Carlo simulations. The main idea is to use the Wang-Landau flat-histogram algorithm, which allows us to obtain the free energy of a lattice model on a torus as a function of torus radii. The central charge is calculated with a good precision from a free energy scaling at the critical point. We apply the method to the Ising, tricritical Ising (Blume-Capel), Potts and site-diluted Ising models, and also discuss estimation of conformal weights.