Problem statement, as written:
Let $f\colon A\rightarrow B$ be a function. Prove that $f$ is surjective if and only if, for every pair of functions $g,h\colon B\rightarrow C$, if $g\circ f = h\circ f$, then $g=h$.
For this problem, there seem to be two issues on restrictions on the sets the functions act on: 1) either $A,B$ are both empty, in which vacuous truth results, or $A$ must be restricted from being empty, if $B$ is non-empty; 2) $C$ must contain at least two elements.
I concluded 1) since, if $B$ is empty, $A$ must be empty to satisfy the definition of function. If $A$ alone is empty, then $f$ cannot be surjective (either by hypothesis, or as a conclusion). Thus, a restriction must be placed on $A$ being non-empty in the problem statement. No?
I concluded 2) since I got to a junction in my proof in which I was unable to proceed without additional premises. After considering some possibilities, the contention that $C$ contain at least two elements seemed a plausible way out of this. [for the record, in “proving” $f$ to be surjective, I supposed the antecedent if the conditional (in that direction). Next, I proceeded by contradiction, supposing (to the contrary) $g\ne h$. If $C$ is unspecified (but non-empty, as otherwise $A,B,C$ are all forced to be empty, and the theorem becomes vacuous), it seems impossible to define $g,h$ by which to arrive at a contradiction.] Am I correct?
Question to answer: are there two omissions in the problem statement which need to appear? Namely, $C$ must be a set with more than one element, and $A$ must be non-empty.