Two Kähler metrics on a complex manifold are called c-projectively equivalent if their $J$-planar curves coincide. These curves are defined by the property that the acceleration is complex proportional to the velocity. We give an explicit local description of all pairs of c-projectively equivalent Kähler metrics of arbitrary signature and use this description to prove the classical Yano-Obata conjecture: we show that on a closed connected Kähler manifold of arbitrary signature, any c-projective vector field is an affine vector field unless the manifold is CPn with (a multiple of) the Fubini-Study metric. As a by-product, we prove the projective Lichnerowicz conjecture for metrics of Lorentzian signature: we show that on a closed connected Lorentzian manifold, any projective vector field is an affine vector field.