Using the Intermediate Value Theorem on two functions?

Homework Statement

Given that f and g are continuous on [a, b], that f(a) < g(a), and g(b) < f(b), show that there exists at least one number c in (a, b) such that f(c) = g(c). HINT: Consider f(x) - g(x).

Homework Equations

If f is continuous on [a, b] and K is a number between f(a) and f(b), then there is at lease one number c between a and b for which f(c) = K.

The Attempt at a Solution

I know the proof for the Intermediate Value Theorem (IVT) is as follows:

Suppose F(a) < K < f(b)
g(x) = f(x) - K is continuous on [a, b], since
g(a) = f(a) - K < 0 and g(b) = f(b) - K > 0
We know there is a number c between a and b for which g(c) = 0
Then, f(c) = K

From the hint it seems to say to make a function p(x) = f(x) - g(x) like how g(x) = f(x) - K in the proof. But I don't know where to go from there... it gets confusing with so many functions!

Put h(x)=f(x)-g(x). Then h(a)<0 and h(b)>0. Thus $$0\in [h(a),h(b)]$$, which implies that h(c)=0 for some c.