I’d add that
the payoff of a call is max(S-X,0)
the payoff of a put is max(X-S,0)

so if you own a call and sell a put with the same strike,
if S>X you exercise the call and receive S-X
if S<X the put is exercised against you and you pay X-S, which is the same as receiving S-X

Either way, you receive S-X, so the payoff from a portfolio consisting of a long call and a short put is S-X
And that’s your long stock and short bond.