Showing $M\cong M'\oplus M''$ given an exact sequence I am struggling with the following question:
$R$ is a ring. $$M'\overset{f}{\longrightarrow} M\overset{g}{\longrightarrow} M''$$ are homomorphisms of $R$-modules such that for any $R$-module $N$, the induced sequence: $$0\to Hom(M'',N)\overset{\bar{g}}{\longrightarrow} Hom(M, N) \overset{\bar{f}}{\longrightarrow} Hom(M',N)\to 0$$ is exact. Show that $M\cong M\oplus M''$.
Here is what I have done so far:
I took $N = M'\oplus M''$ and the natural embeddings $x: M' \to M'\oplus M''$and $y: M''\to M'\oplus M''$.
Since $\bar{f}$ is surjective, there is an element $h \in  Hom(M,M'\oplus M'')$ such that $\bar{f}(h)=x$.
So I tried to show that $h+\bar{g}(y)$ is a homomorphism from $M$ to $M'\oplus M''$. But I could only show that its a monomorphism. Now I know that there are possibly many choices for $h$ and this gives some ambiguity to my map. However, I am struggling to find other ideas.
I am fairly confused on how to approach this question as I have little intuition for how to deal with exact sequences. I would like to be pointed in the right direction. I don't want the answer as I would like to solve it myself but I would appreciate any hints on this! Thank you.
Edit: How do I show that there is an $h$ such that $g(\ker(h))=M''$? 
 A: As you know that for any $N$ you get an exact sequence for the $Hom$ modules, try putting different $N$s. In particular $N=M'$, $N=M''$ and $N=M$ together with their identity homomorphisms. 

More details:
My strategy was to use the following.


*

*Taking $N=M'$ to obtain a map $r:M \to M'$ such that $r \circ f =id_{M'}$. Together with the given $g:M \to M''$ we construct $r\oplus g:M \to M' \oplus M''$.

*Everything fits into a commutative diagram



By the 5-lemma if the top row is exact then $r \circ f$ is an isomorphism.
So we are left to prove that it follows from the exactness of
$0 \to Hom(M'',N) \to Hom(M,N) \to Hom(M',N) \to 0$ for every $N$ that $0 \to M' \to M \to M'' \to 0$ 
is exact.
Since $r \circ f =id_{M'}$ we see that $f$ is injective.
Next consider $N=M''$ and $id_{M''} \in Hom(M'',M'')$.
By exactness $\bar{f} \circ \bar{g}(id_{M''})=0$. From construction $\bar{f} \circ \bar{g}(id_{M''})= id_{M''} \circ g \circ f = g \circ f$. So $Im(f) \subset Ker(g)$.
And so on.
Other candidates for $N$ are $M,Ker(g),M/Im(f)$
Hope this helps.
